class Twitter::REST::Request::MultipartWithFile
Constants
- BMP_REGEX
- CONTENT_TYPE
- GIF_REGEX
- JPEG_REGEX
- PNG_REGEX
- WEBP_REGEX
Public Instance Methods
call(request)
click to toggle source
# 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
Private Instance Methods
mime_type(path)
click to toggle source
# File lib/twitter/rest/request/multipart_with_file.rb, line 24 def mime_type(path) case path when BMP_REGEX 'image/bmp' when GIF_REGEX 'image/gif' when JPEG_REGEX 'image/jpeg' when PNG_REGEX 'image/png' when WEBP_REGEX 'image/webp' else 'application/octet-stream' end end