pub struct StreamUploader<'a, R: 'static + Read + Send + Sync, B = Body> { /* private fields */ }Expand description
Client implementation to upload streams (file-like objects) and videos via the Wistia Upload API.
Also check out the rust-wistia docs for usage and examples.
Implementations§
Source§impl<'a> StreamUploader<'a, Cursor<Bytes>>
impl<'a> StreamUploader<'a, Cursor<Bytes>>
Sourcepub async fn with_url(url: &str) -> Result<StreamUploader<'a, Cursor<Bytes>>>
pub async fn with_url(url: &str) -> Result<StreamUploader<'a, Cursor<Bytes>>>
Create a new StreamUploader which uses the bytes content downloaded
from a publicly accessible url.
§Arguments
url- A public accessible url to the media which will be downloaded.
§Examples
use rust_wistia::{StreamUploader, https::get_https_client};
let mut uploader = StreamUploader::with_url("https://google.com/my/image").await?;Sourcepub async fn with_url_and_token(
url: &str,
access_token: &str,
) -> Result<StreamUploader<'a, Cursor<Bytes>>>
pub async fn with_url_and_token( url: &str, access_token: &str, ) -> Result<StreamUploader<'a, Cursor<Bytes>>>
Create a new StreamUploader which uses the bytes content downloaded
from a publicly accessible url.
§Arguments
url- A public accessible url to the media which will be downloaded.access_token- An API access token used to make requests to the Wistia API.
§Examples
use rust_wistia::{StreamUploader, https::get_https_client};
let mut uploader = StreamUploader::with_url_and_token(
"https://google.com/my/image",
"my-token"
)
.await?;Sourcepub async fn with_url_and_client(
url: &str,
client: impl Into<Option<Client<HttpsConnector<HttpConnector>>>>,
) -> Result<StreamUploader<'a, Cursor<Bytes>>>
pub async fn with_url_and_client( url: &str, client: impl Into<Option<Client<HttpsConnector<HttpConnector>>>>, ) -> Result<StreamUploader<'a, Cursor<Bytes>>>
Create a new StreamUploader which uses the bytes content downloaded
from a publicly accessible url.
§Arguments
url- A public accessible url to the media which will be downloaded.client- An optional HTTPS client to use for downloading the media.
§Examples
use rust_wistia::{StreamUploader, https::get_https_client};
let client = get_https_client();
let mut uploader = StreamUploader::with_url_and_client("https://google.com/my/image", client).await?;Sourcepub async fn with_url_and_arc_client(
url: &str,
client: Arc<Client<HttpsConnector<HttpConnector>>>,
) -> Result<StreamUploader<'a, Cursor<Bytes>>>
pub async fn with_url_and_arc_client( url: &str, client: Arc<Client<HttpsConnector<HttpConnector>>>, ) -> Result<StreamUploader<'a, Cursor<Bytes>>>
Create a new StreamUploader which uses the bytes content downloaded
from a publicly accessible url.
§Arguments
url- A public accessible url to the media which will be downloaded.client- An optional HTTPS client to use for downloading the media.
§Examples
use std::sync::Arc;
use rust_wistia::{StreamUploader, https::get_https_client};
let client = Arc::new(get_https_client());
let mut uploader = StreamUploader::with_url_and_arc_client("https://google.com/my/image", client).await?;Source§impl<'a, R: 'static + Read + Send + Sync> StreamUploader<'a, R>
impl<'a, R: 'static + Read + Send + Sync> StreamUploader<'a, R>
Sourcepub fn new(stream: R) -> Result<Self>
pub fn new(stream: R) -> Result<Self>
Create a StreamUploader with a new HTTPS client, with the access token
retrieved from the environment.
§Arguments
stream- A readable file-like stream object to upload.
§Examples
use rust_wistia::StreamUploader;
use std::io::Cursor;
let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::new(bytes)?;
let res = uploader.name("My Video Name").send()?.await?;Sourcepub fn with_stream_and_filename(stream: R, file_name: &'a str) -> Result<Self>
pub fn with_stream_and_filename(stream: R, file_name: &'a str) -> Result<Self>
Create a SteamUploader with a new HTTPS client, with the access token
retrieved from the environment.
§Arguments
stream- A readable file-like stream object to upload.file_name- The name of the media file.
§Examples
use rust_wistia::StreamUploader;
use std::io::Cursor;
let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::with_stream_and_filename(bytes, "my_file.mp4")?;
let res = uploader.send()?.await?;Sourcepub fn with_filename(file_name: &'a str) -> Result<Self>
pub fn with_filename(file_name: &'a str) -> Result<Self>
Create a SteamUploader with a new HTTPS client, with the access token
retrieved from the environment.
§Arguments
file_name- The name of the media file.
§Examples
use rust_wistia::StreamUploader;
use std::io::Cursor;
let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::with_filename("my_file.mp4")?.stream(bytes);
let res = uploader.send()?.await?;Sourcepub fn with_token(access_token: &str) -> Self
pub fn with_token(access_token: &str) -> Self
Create a SteamUploader with a new HTTPS client and a Wistia access
token.
§Arguments
access_token- An API access token used to make requests to the Wistia API.
§Examples
use rust_wistia::StreamUploader;
use std::io::Cursor;
let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::with_token("my-token").stream(bytes);
let res = uploader.send()?.await?;Sourcepub fn with_client(client: UploadClient<Body>) -> Self
pub fn with_client(client: UploadClient<Body>) -> Self
Create a SteamUploader with a file path and an HTTPS client.
§Arguments
client- The HTTPS client (UploadClient) to use for requests. Note that the client must support multipart form requests, via amultipart::Body.
§Examples
use rust_wistia::{StreamUploader, UploadClient};
use std::io::Cursor;
let client = UploadClient::from_env()?;
let bytes = Cursor::new("Hello World!");
let uploader = StreamUploader::with_client(client).stream(bytes);
let res = uploader.send()?.await?;Sourcepub fn stream(self, stream: R) -> Self
pub fn stream(self, stream: R) -> Self
Sets the reader stream which will be used to upload to Wistia.
§Examples
use std::io::Cursor;
let bytes = Cursor::new("Hello World!");
let uploader = rust_wistia::StreamUploader::with_filename("my_file.mp4")?.stream(bytes);Sourcepub fn project_id(self, project_id: &'a str) -> Self
pub fn project_id(self, project_id: &'a str) -> Self
The hashed id of the project to upload media into. If omitted, a new
project will be created and uploaded to. The naming convention used
for such projects is Uploads_YYYY-MM-DD.
Sourcepub fn name(self, name: &'a str) -> Self
pub fn name(self, name: &'a str) -> Self
A display name to use for the media in Wistia. If omitted, the filename will be used instead. This field is limited to 255 characters.
Sourcepub fn description(self, description: &'a str) -> Self
pub fn description(self, description: &'a str) -> Self
A description to use for the media in Wistia. You can use basic HTML here, but note that both HTML and CSS will be sanitized.
Sourcepub fn contact_id(self, contact_id: &'a str) -> Self
pub fn contact_id(self, contact_id: &'a str) -> Self
A Wistia contact id, an integer value. If omitted, it will default to the contact_id of the account’s owner.
Sourcepub async fn send(self) -> Result<UploadResponse>
pub async fn send(self) -> Result<UploadResponse>
Send the Upload File request (with the multi-part form data) to the Wistia Upload API.