From 0e277923badd6f2ba4e1bffa0d0578f88879bb10 Mon Sep 17 00:00:00 2001 From: tahashahid Date: Sat, 14 Mar 2020 19:27:25 +0500 Subject: [PATCH] added user defned media_category support for direct message we need to define the media category: dm_image, dm_gif, dm_video https://developer.twitter.com/en/docs/direct-messages/message-attachments/guides/attaching-media --- lib/file_uploader.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/file_uploader.js b/lib/file_uploader.js index ffaf1b94..28d1b3db 100644 --- a/lib/file_uploader.js +++ b/lib/file_uploader.js @@ -22,6 +22,7 @@ var FileUploader = function (params, twit) { assert(params.file_path, 'Must specify `file_path` to upload a file. Got: ' + params.file_path + '.') var self = this; self._file_path = params.file_path; + self._media_category = params.media_category self._twit = twit; self._isUploading = false; self._isFileStreamEnded = false; @@ -134,7 +135,7 @@ FileUploader.prototype._initMedia = function (cb) { } else if (mediaType.toLowerCase().indexOf('video') > -1) { media_category = 'tweet_video'; } - + media_category = self._media_category || media_category; // Check the file size - it should not go over 15MB for video. // See https://dev.twitter.com/rest/reference/post/media/upload-chunked if (mediaFileSizeBytes < MAX_FILE_SIZE_BYTES) {