#azure-storage #azure-sdk #azure #storage #blob #blobs #sdk

azure_storage_blobs

Azure Blob Storage crate from the Azure SDK for Rust

18 breaking releases

0.19.0 Jan 5, 2024
0.18.0 Dec 11, 2023
0.17.0 Nov 3, 2023
0.13.1 Jul 6, 2023
0.1.0 Jan 25, 2022

#62 in Network programming

Download history 3785/week @ 2023-12-23 8752/week @ 2023-12-30 12649/week @ 2024-01-06 14390/week @ 2024-01-13 17006/week @ 2024-01-20 18537/week @ 2024-01-27 20660/week @ 2024-02-03 18223/week @ 2024-02-10 17160/week @ 2024-02-17 17993/week @ 2024-02-24 17628/week @ 2024-03-02 20779/week @ 2024-03-09 25893/week @ 2024-03-16 19958/week @ 2024-03-23 20290/week @ 2024-03-30 21567/week @ 2024-04-06

91,084 downloads per month
Used in 9 crates

MIT license

6MB
103K SLoC

azure_storage_blobs

This crate is from the Azure SDK for Rust. It supports Azure Blob Storage.

Example


use azure_core::error::{ErrorKind, ResultExt};
use azure_storage::prelude::*;
use azure_storage_blobs::prelude::*;
use futures::stream::StreamExt;

#[tokio::main]
async fn main() -> azure_core::Result<()> {
    let file_name = "azure_sdk_for_rust_stream_test.txt";

    // First we retrieve the account name and access key from environment variables.
    let account = std::env::var("STORAGE_ACCOUNT").expect("missing STORAGE_ACCOUNT");
    let access_key = std::env::var("STORAGE_ACCESS_KEY").expect("missing STORAGE_ACCOUNT_KEY");
    let container = std::env::var("STORAGE_CONTAINER").expect("missing STORAGE_CONTAINER");
    let blob_name = std::env::var("STORAGE_BLOB_NAME").expect("missing STORAGE_BLOB_NAME");

    let storage_credentials = StorageCredentials::access_key(account.clone(), access_key);
    let blob_client = ClientBuilder::new(account, storage_credentials).blob_client(&container, blob_name);

    blob_client.put_block_blob("hello world").content_type("text/plain").await?;

    let mut result: Vec<u8> = vec![];

    // The stream is composed of individual calls to the get blob endpoint
    let mut stream = blob_client.get().into_stream();
    while let Some(value) = stream.next().await {
        let mut body = value?.data;
        // For each response, we stream the body instead of collecting it all
        // into one large allocation.
        while let Some(value) = body.next().await {
            let value = value?;
            result.extend(&value);
        }
    }

    println!("result: {:?}", result);

    Ok(())
}

License: MIT

Dependencies

~8–25MB
~369K SLoC