Skip to content

Commit

Permalink
Merge pull request #1037 from rajyan/add-mov-upload
Browse files Browse the repository at this point in the history
add mov chunk_uplaod
  • Loading branch information
sferik committed Sep 19, 2023
2 parents 154e66b + a57a597 commit 63e6e29
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/twitter/rest/upload_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ module UploadUtils
#
# @see https://developer.twitter.com/en/docs/media/upload-media/uploading-media/media-best-practices
def upload(media, media_category_prefix: "tweet")
return chunk_upload(media, "video/mp4", "#{media_category_prefix}_video") if File.extname(media) == ".mp4"
return chunk_upload(media, "image/gif", "#{media_category_prefix}_gif") if File.extname(media) == ".gif" && File.size(media) > 5_000_000
ext = File.extname(media)
return chunk_upload(media, "video/mp4", "#{media_category_prefix}_video") if ext == ".mp4"
return chunk_upload(media, "video/quicktime", "#{media_category_prefix}_video") if ext == ".mov"
return chunk_upload(media, "image/gif", "#{media_category_prefix}_gif") if ext == ".gif" && File.size(media) > 5_000_000

Twitter::REST::Request.new(self, :multipart_post, "https://upload.twitter.com/1.1/media/upload.json", key: :media, file: media).perform
end
Expand Down

0 comments on commit 63e6e29

Please sign in to comment.