Function imagevault::service::media_service::save[][src]

pub async fn save<T: Authentication + Sync>(
    client: &Client<T>,
    media_items: Vec<&MediaItem>,
    save_options: MediaServiceSaveOptions
) -> Result<(), ImageVaultError>
Expand description

Calls mediaservice/save.

Returns an AuthenticationMissing error if the Client does not have any Authentication set.

Arguments

  • client - The ImageVault Client to use.
  • media_items - A list of MediaItems to save.
  • save_options - A MediaServiceSaveOption describing what to save.

Examples

use std::path::Path;
use imagevault::{
    service::media_content_service,
    service::upload_service,
    service::media_service,
    service::media_service::MediaServiceSaveOptions,
    Client,
    authentication::ClientCredentialsAuthentication
};

let authentication = ClientCredentialsAuthentication::default();
let client = Client::new(
    "identity",
    "secret",
    "https://myimagevault.local"
    )?
    .with_authentication(authentication);

// Upload a file
let file_path = Path::new("my_image.jpg");
let upload_file_id = upload_service::upload_from_path(
    &client,
    file_path
    )
    .await?;

// Store uploaded content in vault 42
let media_item = media_content_service::store_content_in_vault_from_path(
    &client,
    file_path,
    &upload_file_id,
    42
    )
    .await?;

// Mark the newly uploaded content as organized
let save_result = media_service::save(
    &client,
    vec![&media_item],
    MediaServiceSaveOptions::MarkAsOrganized
    )
    .await?;