Skip to content

[bug] Error when uploading GIFs  #519

Open
@anaisberg

Description

@anaisberg

Describe the bug
When trying to upload GIFs using the uploadMedia endpoint, I get an {"code":1,"name":"InvalidMedia"} error.
Uploading images works well with png/jpg however.

To Reproduce
Please indicate all steps that lead to this bug:

  1. Request client setup (login method, OAuth2 scopes if applicable...)
 import { TwitterApi } from 'twitter-api-v2';
 const client = new TwitterApi({
    appKey: XXXX,
    appSecret: XXXX,
    accessToken: XXXX,
    accessSecret: XXXX,
 });
  1. Endpoint used or code example of what's happening wrong
const mediaId = await client.v1.uploadMedia('./paris.gif', {
  mimeType: 'image/gif,
});
  1. Error stack trace, and if possible, error content (err.toJSON() when err is the caught error; take care of removing authentication HTTP headers)
{
"media_id":1763597253904670720,
"media_id_string":"1763597253904670720",
"media_key":"16_1763597253904670720",
"size":384852,
"processing_info":{
  "state":"failed",
  "progress_percent":99,
  "error": {"code":1,"name":"InvalidMedia"}
  }
} 

Expected behavior
The gifs is uploaded, state success

Version

  • Node.js version : v18
  • Lib version : "twitter-api-v2": "^1.15.0"
  • OS (especially if you use Windows) : macOs 14.3.1

Additional context

After looking into the code, I realized that the media_category computed for gifs is TweetGif (in the getMediaCategoryByMime function), where in the API documentation, it is specified that the media_category should be tweet_gif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions