Crates.io | azure_blob_uploader |
lib.rs | azure_blob_uploader |
version | 0.1.4 |
source | src |
created_at | 2023-11-07 20:47:07.555055 |
updated_at | 2023-11-08 16:51:14.688048 |
description | A simple crate to help you upload files to Azure Blob Storage |
homepage | https://github.com/Somsubro-Banerjee/azure_blob_uploader |
repository | https://github.com/Somsubro-Banerjee/azure_blob_uploader |
max_upload_size | |
id | 1028432 |
size | 87,737 |
Usage:
use azure_blob_uploader::azure_blob_uploader::AzureBlobUploader; // Import the Crate
mod secrets;
#[tokio::main]
async fn main() {
let file_path = "/path/to/your/file"; // Define path to your file
let uploader = AzureBlobUploader::upload_file_to_blob_storage( // Create a Uploader object and call the `azure_blob_uploader()` function.
file_path,
secrets::STORAGE_ACCOUNT,
secrets::STORAGE_KEY,
secrets::STORAGE_CONTAINER,
secrets::STORAGE_BLOB,
10, // The chunk size is in Mb. Here in example the chunk is set to 10Mb.
)
.await;
match uploader {
Ok(value) => println!("blob url: {:#?}", value), // Use pattern matching to get the output.
Err(_) => println!("Some Error Occurred!"),
}
}
Initialize the AzureBlobUploader
and call the upload_file_to_blob_storage()
function
file_path
will have the location of the file you want to upload.
STORAGE_ACCOUNT
is bascially the name of the storage account.
STORAGE_KEY
is the Key to access the storage account.
STORAGE_CONTAINER
is the name of the storage container present in the storage account.
STORAGE_BLOB
is the name of the blob object.
Lastly we are passing the chunk size which is of type usize
.
By default the chunk size is set in Mb, so here 10
represents 10Mb chunks.
After the file transfer is completed it returns the link of the storage blob that you can leverage to use it further.