Skip to content

Commit

Permalink
Add additional mime_types for multi-part upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Sep 6, 2015
1 parent afd41a3 commit 947fcdc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/twitter/rest/request/multipart_with_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ module REST
class Request
class MultipartWithFile < Faraday::Middleware
CONTENT_TYPE = 'Content-Type'
BMP_REGEX = /\.bmp/i
GIF_REGEX = /\.gif$/i
JPEG_REGEX = /\.jpe?g/i
PNG_REGEX = /\.png$/i
WEBP_REGEX = /\.webp/i

def call(request)
request.body.each do |key, value|
Expand All @@ -21,12 +23,16 @@ def call(request)

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
Expand Down

0 comments on commit 947fcdc

Please sign in to comment.