Class: Twitter::REST::Request::MultipartWithFile

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/twitter/rest/request/multipart_with_file.rb

Constant Summary collapse

CONTENT_TYPE =
'Content-Type'.freeze
BMP_REGEX =
/\.bmp/i
GIF_REGEX =
/\.gif$/i
JPEG_REGEX =
/\.jpe?g/i
PNG_REGEX =
/\.png$/i
WEBP_REGEX =
/\.webp/i

Instance Method Summary collapse

Instance Method Details

#call(request) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/twitter/rest/request/multipart_with_file.rb', line 14

def call(request)
  request.body.each do |key, value|
    next unless value.respond_to?(:to_io)
    request.body[key] = Faraday::UploadIO.new(value, mime_type(value.path), value.path)
  end if request.body.is_a?(::Hash)
  @app.call(request)
end