Class: Uploadcare::Client::FileClient

Inherits:
RestClient
  • Object
show all
Defined in:
lib/uploadcare/client/file_client.rb

Overview

API client for handling single files

Instance Method Summary collapse

Methods inherited from RestClient

#api_root, #api_struct_delete, #api_struct_get, #api_struct_post, #api_struct_put, #get, #headers, #post, #put, #request

Methods included from Uploadcare::Concerns::ThrottleHandler

#handle_throttling

Methods included from Uploadcare::Concerns::ErrorHandler

#failure, #wrap

Instance Method Details

#delete(uuid) ⇒ Object



37
38
39
# File 'lib/uploadcare/client/file_client.rb', line 37

def delete(uuid)
  request(method: 'DELETE', uri: "/files/#{uuid}/storage/")
end

#indexObject

Gets list of files without pagination fields



12
13
14
15
# File 'lib/uploadcare/client/file_client.rb', line 12

def index
  response = get(uri: '/files/')
  response.fmap { |i| i[:results] }
end

#info(uuid, params = {}) ⇒ Object Also known as: file

Acquire file info



19
20
21
# File 'lib/uploadcare/client/file_client.rb', line 19

def info(uuid, params = {})
  get(uri: "/files/#{uuid}/", params: params)
end

#local_copy(options = {}) ⇒ Object



25
26
27
28
# File 'lib/uploadcare/client/file_client.rb', line 25

def local_copy(options = {})
  body = options.compact.to_json
  post(uri: '/files/local_copy/', content: body)
end

#remote_copy(options = {}) ⇒ Object



31
32
33
34
# File 'lib/uploadcare/client/file_client.rb', line 31

def remote_copy(options = {})
  body = options.compact.to_json
  post(uri: '/files/remote_copy/', content: body)
end

#store(uuid) ⇒ Object

Store a single file, preventing it from being deleted in 2 weeks



43
44
45
# File 'lib/uploadcare/client/file_client.rb', line 43

def store(uuid)
  put(uri: "/files/#{uuid}/storage/")
end