pub async fn upload(
        &self,
        content_type: &str,
        reader: &mut impl Read,
    ) -> Result<create_content::Response> {
        let mut data = Vec::new();
        reader.read_to_end(&mut data)?;

        let request = create_content::Request::new(content_type, data);

        self.http_client.upload(request).await
    }
/// Upload some media to the server.
///
/// # Arguments
///
/// * `content_type` - The type of the media, this will be used as the
/// content-type header.
///
/// * `reader` - A `Reader` that will be used to fetch the raw bytes of the
/// media.
///
/// # Examples
///
/// ```no_run
/// # use std::{path::PathBuf, fs::File, io::Read};
/// # use matrix_sdk::{Client, identifiers::room_id};
/// # use url::Url;
/// # use futures::executor::block_on;
/// # block_on(async {
/// # let homeserver = Url::parse("http://localhost:8080").unwrap();
/// # let mut client = Client::new(homeserver).unwrap();
/// let path = PathBuf::from("/home/example/my-cat.jpg");
/// let mut image = File::open(path).unwrap();
///
/// let response = client
///     .upload("image/jpg", &mut image)
///     .await
///     .expect("Can't upload my cat.");
///
/// println!("Cat URI: {}", response.content_uri);
/// # });
/// ```
Upload some media to the server.
Upload some media to the server .
pub async fn upload(
        &self,
        content_type: &str,
        reader: &mut impl Read,
    ) -> Result<create_content::Response> {
        let mut data = Vec::new();
        reader.read_to_end(&mut data)?;
        let request = create_content::Request::new(content_type, data);
        self.http_client.upload(request).await
    }
pub async fn upload ( & self , content_type : & str , reader : & mut impl Read , ) -> Result < create_content :: Response > { let mut data = Vec :: new ( ) ; reader . read_to_end ( & mut data ) ? ; let request = create_content :: Request :: new ( content_type , data ) ; self . http_client . upload ( request ) . await }
Upload some media to the server.
Upload some media to the server .
&self
content_type
&str
reader
&mut impl Read
&self
content_type
&str
reader
&mut impl Read
examples
None
use std::{path::pathbuf, fs::file, io::read};
None
use matrix_sdk::{client, identifiers::room_id};
None
use url::url;
None
use futures::executor::block_on;
None
block_on(async {
None
let homeserver = url::parse("http://localhost:8080").unwrap();
None
let mut client = client::new(homeserver).unwrap();
let path = PathBuf::from("/home/example/my-cat.jpg");
let mut image = File::open(path).unwrap().

let response = client
.upload("image/jpg", &mut image)
.await
.expect("Can't upload my cat.").

println!("Cat URI: {}", response.content_uri).
let path = PathBuf :: from ( " / home / example / my - cat . jpg " ) ; let mut image = File :: open ( path ) . unwrap () . let response = client . upload ( " image / jpg " &mut image ) . await . expect ( " Can ' t upload my cat . " ) . println! ( " Cat URI : {} " response . content_uri ) .
});
None