From a57a59709424c8c9692bc6e32efd6470b597c9b6 Mon Sep 17 00:00:00 2001 From: Yohta Kimura Date: Tue, 20 Jun 2023 17:33:47 +0900 Subject: [PATCH] add mov chunk_uplaod --- lib/twitter/rest/upload_utils.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/twitter/rest/upload_utils.rb b/lib/twitter/rest/upload_utils.rb index c2704372e..6c1e76caf 100644 --- a/lib/twitter/rest/upload_utils.rb +++ b/lib/twitter/rest/upload_utils.rb @@ -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