Overview
This node uploads media files (specifically images) to Twitter using the Twitter API. It is designed to handle binary image data from previous nodes or optionally accept media data as a string. The node supports setting additional owners who can use the uploaded media and categorizing the media for different Twitter contexts such as tweets or videos.
Common scenarios where this node is beneficial include:
- Automating the upload of images to Twitter as part of a social media workflow.
- Preparing media assets for tweets, GIFs, or videos programmatically.
- Managing media ownership by specifying additional users allowed to use the media.
Practical example:
- A user has an automation that collects images from various sources, processes them, and then uploads them to Twitter with appropriate media categories and ownership settings for collaborative accounts.
Properties
| Name | Meaning |
|---|---|
| Binary Property | Name of the binary property that contains the image data to be uploaded. |
| Media Data | Optional media data as a string; if provided, it overrides the binary property input. |
| Additional Owners | Comma-separated list of user IDs (up to 100) who are allowed to use the media in addition to the uploader. |
| Media Category | Category representing how the media will be used on Twitter. Options include: tweet_image (default), tweet_gif, tweet_video. |
Output
The node outputs JSON data containing the response from Twitter's media upload endpoint. The output includes:
success: Boolean indicating whether the upload was successful.- Other fields returned by Twitter's API related to the uploaded media, such as media ID and processing info.
- In case of failure (when "Continue On Fail" is enabled), the output includes:
success: falseerror: Error message describing what went wrong.details: Additional error details from the Twitter API response if available.
The node does not output binary data itself but works with binary input data.
Dependencies
- Requires valid Twitter API credentials with OAuth1 authentication (consumer key/secret and access token/secret).
- Uses the Twitter API endpoint
https://upload.twitter.com/1.1/media/upload.json. - Utilizes the
form-datapackage to construct multipart form requests. - Requires n8n environment configured with Twitter API credentials.
Troubleshooting
- Missing Credentials: If no Twitter credentials are provided or any required OAuth keys/secrets are missing, the node throws an error. Ensure all four OAuth credentials are set correctly.
- Binary Data Not Found: If the specified binary property does not exist or does not contain image data, the node attempts to find an alternative image binary property. If none found, it errors out.
- Invalid Media Type: Only image MIME types are supported. Uploading non-image media will cause an error.
- Additional Owners Limit: Specifying more than 100 additional owners results in an error.
- API Errors: HTTP status codes >= 400 from Twitter API result in errors. Check the error message and ensure the media data and credentials are correct.
- Media Data Parameter: If both binary data and mediaData string are provided, mediaData takes precedence.
To resolve common issues:
- Verify credentials and permissions.
- Confirm the binary property name matches the actual binary data.
- Ensure media files are valid images.
- Limit additional owners to 100 or fewer.
- Use the "Continue On Fail" option to handle errors gracefully in workflows.