Function imagevault::service::upload_service::upload_from_content
source · [−]pub async fn upload_from_content<T: Authentication + Sync, P: Read>(
client: &Client<T>,
content: P
) -> Result<String, ImageVaultError>
Expand description
Calls uploadservice/upload
.
Returns an AuthenticationMissing
error
if the Client
does not have any Authentication
set.
Arguments
client
- The ImageVaultClient
to use.content
- AnyRead
data to be uploaded, e.g. a file.
Examples
use std::path::Path;
use std::fs::File;
use imagevault::{
service::upload_service,
Client,
authentication::ClientCredentialsAuthentication
};
let authentication = ClientCredentialsAuthentication::default();
let client = Client::new(
"identity",
"secret",
"https://myimagevault.local"
)?
.with_authentication(authentication);
let file_path = Path::new("my_image.jpg");
let file = File::open(file_path)?;
let upload_file_id = upload_service::upload_from_content(
&client,
&file
)
.await?;