Function imagevault::service::upload_service::upload_from_content[][src]

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 ImageVault Client to use.
  • content - Any Read 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?;