uploadImage abstract method

Future<TwitterResponse<UploadedMediaData, void>> uploadImage({
  1. required File file,
  2. String? altText,
  3. List<String>? additionalOwners,
})

Use this endpoint to upload images to Twitter.

This endpoint is suited for simple image uploads with small file sizes and is faster than uploadMedia. However, this endpoint has restrictions on upload size and format, so use uploadMedia when uploading large files or videos.

Also, media with a file size of 0 cannot be uploaded.

Caution

This method uses the v1.1 endpoint. Therefore, the arguments and returned object of this method may change in the future when the v2.0 endpoint for uploading images is released.

If an error occurs when uploading media, TwitterUploadException is always thrown.

Usage

This is a simple image upload endpoint with a limited set of features. The preferred alternative is the chunked upload endpoint which supports both images and videos, provides better reliability, allows resumption of file uploads, and other important features. In the future, new features will only be supported for the chunked upload endpoint.

Parameters

  • file: The raw binary image content being uploaded.

  • altText: Additional descriptive text to be added to images and GIFs. The text must be <= 1000 chars.

  • additionalOwners: A list of user IDs to set as additional owners allowed to use the returned media id in Tweets or Cards. Up to 100 additional owners may be specified.

Endpoint Url

Authentication Methods

  • OAuth 1.0a

Reference

Implementation

Future<TwitterResponse<UploadedMediaData, void>> uploadImage({
  required File file,
  String? altText,
  List<String>? additionalOwners,
});