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

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

Constant Summary

CONTENT_TYPE =
'Content-Type'
GIF_REGEX =
/\.gif$/i
JPEG_REGEX =
/\.jpe?g/i
PNG_REGEX =
/\.png$/i

Instance Method Summary (collapse)

Instance Method Details

- (Object) call(request)



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

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