Expand description
§🐻❄️🧶 remi_azure
This crate is an official implementation of remi::StorageService
for Microsoft’s
Azure Blob Storage service using the unofficial Azure crates: azure_core
, azure_storage
,
and azure_storage_blobs
.
§Example
// Cargo.toml:
//
// [dependencies]
// remi = "^0"
// remi-azure = "^0"
// tokio = { version = "^1", features = ["full"] }
use remi_azure::{StorageService, StorageConfig, Credential, CloudLocation};
use remi::{StorageService as _, UploadRequest};
#[tokio::main]
async fn main() {
let storage = StorageService::new(StorageConfig {
credentials: Credential::Anonymous,
container: "my-container".into(),
location: CloudLocation::Public("my-account".into()),
}).unwrap();
// Initialize the container. This will:
//
// * create `my-container` if it doesn't exist
storage.init().await.unwrap();
// Now we can upload files to Azure.
// We define a `UploadRequest`, which will set the content type to `text/plain` and set the
// contents of `weow.txt` to `weow fluff`.
let upload = UploadRequest::default()
.with_content_type(Some("text/plain"))
.with_data("weow fluff");
// Let's upload it!
storage.upload("weow.txt", upload).await.unwrap();
// Let's check if it exists! This `assert!` will panic if it failed
// to upload.
assert!(storage.exists("weow.txt").await.unwrap());
}
§Crate Features
Crate Features | Description | Enabled by default? |
---|---|---|
export-azure | Exports all the used Azure crates as a module called core | No. |
unstable | Tap into unstable features from remi_azure and the remi crate. | No. |
tracing | Enables the use of tracing::instrument and emit events for actions by the crate. | No. |
serde | Enables the use of serde in StorageConfig | No. |
log | Emits log records for actions by the crate | No. |
Modules§
- core
export-azure
- Exports the
azure_core
,azure_storage
, andazure_storage_blobs
crates without defining them as owned dependencies.
Structs§
Enums§
- Cloud
Location - Newtype enumeration around
azure_storage::CloudLocation
. - Credential
- Credentials information for creating a blob container.