Class: Vox::HTTP::UploadIO

Inherits:
Faraday::UploadIO
  • Object
show all
Defined in:
lib/vox/http/upload_io.rb

Overview

Wrapper to faraday’s UploadIO that allows for an optional MIME type

Instance Method Summary collapse

Constructor Details

#initialize(file, mime_type = nil, name = nil) ⇒ UploadIO

Returns a new instance of UploadIO.

Parameters:

  • file (File, IO, String)

    A File, IO, or file path for the upload.

  • mime_type (String) (defaults to: nil)

    The MIME type for the file, if ‘nil` it will be inferred from the file path, defaulting to ’application/octet-stream’ if no matching MIME type matches.

  • name (String) (defaults to: nil)

    File name, this can be omitted if the provided file responds to ‘path`.



17
18
19
20
# File 'lib/vox/http/upload_io.rb', line 17

def initialize(file, mime_type = nil, name = nil)
  mime_type ||= mime_for_file(file.respond_to?(:path) ? file.path : file)
  super(file, mime_type, name)
end