Module: ADNReborn::API::File
- Defined in:
- lib/adn-reborn/api/file.rb
Class Method Summary collapse
- .by_id(file_id) ⇒ Object
- .create(filename, params) ⇒ Object
- .delete(file_id) ⇒ Object
- .retrieve(file_id) ⇒ Object
Class Method Details
.by_id(file_id) ⇒ Object
27 28 29 |
# File 'lib/adn-reborn/api/file.rb', line 27 def self.by_id(file_id) self.retrieve(file_id) end |
.create(filename, params) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/adn-reborn/api/file.rb', line 8 def self.create(filename, params) string_io = StringIO.new(params.to_json) content = UploadIO.new(filename, MIME::Types.type_for(filename)[0]) = UploadIO.new(string_io, "application/json", "data") http_params = { "content" => content, # make a fake file so we can still pass json "metadata" => } ADNReborn::API.post_multipart("#{ADNReborn::API_ENDPOINT_FILES}", http_params) end |
.delete(file_id) ⇒ Object
31 32 33 |
# File 'lib/adn-reborn/api/file.rb', line 31 def self.delete(file_id) ADNReborn::API.delete("#{ADNReborn::API_ENDPOINT_FILES}/#{file_id}") end |
.retrieve(file_id) ⇒ Object
23 24 25 |
# File 'lib/adn-reborn/api/file.rb', line 23 def self.retrieve(file_id) ADNReborn::API.get("#{ADNReborn::API_ENDPOINT_FILES}/#{file_id}") end |