[−][src]Module egg_mode::media
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 way this works in egg-mode is to
create an UploadBuilder
and turn that into an UploadFuture
, which manages the upload
process.
For example, here's a basic use of UploadFuture
to upload an image, then attach it to a
tweet:
use tokio::runtime::current_thread::block_on_all; use egg_mode::media::{UploadBuilder, media_types}; use egg_mode::tweet::DraftTweet; let image = vec![]; //pretend we loaded an image file into this let builder = UploadBuilder::new(image, media_types::image_png()); let media_handle = block_on_all(builder.call(&token)).unwrap(); let draft = DraftTweet::new("Hey, check out this cute cat!") .media_ids(&[media_handle.id]); let tweet = block_on_all(draft.send(&token)).unwrap();
For more information, see the UploadBuilder
documentation.
Modules
media_types | A collection of convenience functions that return media types accepted by Twitter. |
Structs
MediaHandle | A media handle returned by twitter upon successful upload. |
UploadBuilder | Represents a media upload before it is sent. |
UploadError | A wrapper for |
UploadFuture | A |
Enums
UploadState | Represents the status of an |