Class: Buble::FilesResource

Inherits:
Object
  • Object
show all
Defined in:
lib/buble/files.rb

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ FilesResource

Returns a new instance of FilesResource.



33
34
35
# File 'lib/buble/files.rb', line 33

def initialize(http)
  @http = http
end

Instance Method Details

#upload(file, file_type: nil, model: nil, mode: nil, **fields) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/buble/files.rb', line 37

def upload(file, file_type: nil, model: nil, mode: nil, **fields)
  upload = coerce_upload(file)
  @http.multipart(
    '/api/v1/files',
    fields: { file_type: file_type, model: model, mode: mode }.merge(fields),
    file: upload.to_http_part
  )
end