get_download_authorization

Function get_download_authorization 

Source
pub async fn get_download_authorization<'a, C, E>(
    auth: &mut Authorization<C>,
    download_req: DownloadAuthorizationRequest<'_>,
) -> Result<DownloadAuthorization<C>, Error<E>>
where C: HttpClient<Error = Error<E>>, E: Debug + Display,
Expand description

Generate a download authorization token to download files with a specific prefix from a private B2 bucket.

The Authorization token must have Capability::ShareFiles.

The returned DownloadAuthorization can be passed to download_file in place of an Authorization when downloading files by name.

See https://www.backblaze.com/b2/docs/b2_get_download_authorization.html for further information.

ยงExamples

let mut auth = authorize_account(
    SurfClient::default(),
    "MY KEY ID",
    "MY KEY"
).await?;

let download_req = DownloadAuthorizationRequest::builder()
    .bucket_id("MY BUCKET ID")
    .file_name_prefix("my/files/")?
    .duration(chrono::Duration::seconds(60))?
    .build()?;

let download_auth = get_download_authorization(&mut auth, download_req)
    .await?;