Module egg_mode::media[][src]

Expand description

Functionality to upload images, GIFs, and videos that can be attached to tweets.

Tweet media is uploaded separately from the act of posting the tweet itself. In order to attach an image to a new tweet, you need to upload it first, then take the Media ID that Twitter generates and reference that when posting the tweet. The media id is returned as part of the result of a call to upload_media.

Here’s a basic example of uploading an image and attaching to a tweet:

use egg_mode::media::{upload_media, media_types};
use egg_mode::tweet::DraftTweet;

let image = b"some image bytes"; //pretend we loaded an image file into this
let handle = upload_media(image, &media_types::image_png(), &token).await?;
let draft = DraftTweet::new("Hey, check out this cute cat!");
draft.add_media(handle.id);
let tweet = draft.send(&token).await?;

Modules

A collection of convenience functions that return media types accepted by Twitter.

Structs

A handle representing uploaded media.

An opaque type representing a media id.

Enums

Upload progress info.

Functions

Check the status of uploaded media

Set metadata for a media upload. At the moment the only attribute that may be set is alt_text.

Upload media to the server.

Upload media to the server, for use in a Direct Message.