5 releases
0.1.4 | Nov 8, 2023 |
---|---|
0.1.3 | Nov 8, 2023 |
0.1.2 | Nov 8, 2023 |
0.1.1 | Nov 7, 2023 |
0.1.0 | Nov 7, 2023 |
#4 in #blob-storage
27KB
58 lines
A simple crate to help you upload your files to Azure Blob Storage
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.
Dependencies
~11–19MB
~263K SLoC