Function imagevault::service::media_content_service::store_content_in_vault_from_path[][src]

pub async fn store_content_in_vault_from_path<T: Authentication + Sync>(
    client: &Client<T>,
    path: &Path,
    upload_file_id: &str,
    vault_id: u64
) -> Result<MediaItem, ImageVaultError>
Expand description

Calls mediacontentservice/storecontentinvault.

File name and content type will be set from the path.

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

Arguments

  • client - The ImageVault Client to use.
  • path - Path to stored file, for getting name and content type.
  • upload_file_id - The file id to store, returned from upload_service/upload.
  • vault_id - The vault to store the content in.

Examples

use std::path::Path;
use imagevault::{
    service::media_content_service,
    service::upload_service,
    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?;