This crate provides wasmCloud actors with an interface to the blobstore capability provider.
Actors using this interface must have the claim wasmcloud:blobstore
in order to have
permission to communicate with the store.
This generic protocol can be used to support capability providers like local blob storage, Amazon S3, Azure blob storage, Google blob storage, and more.
Example: ```rust extern crate wapcguest as guest; use guest::prelude::*; use wasmcloudactorblobstore as blobstore; use wasmcloudactorhttpserver as http; use wasmcloudactorcore::serialize; use blobstore::*; use serde_json::json; use log::{error, info};
pub fn wapcinit() { http::Handlers::registerhandlerequest(downloadpoem); blobstore::Handlers::registerreceivechunk(handlechunk); actorcore::Handlers::registerhealthrequest(health); }
/// Start the download of a blob (poem). Chunks will be streamed after download begins
fn downloadpoem(req: http::Request) -> HandlerResulthttp::Response {
let streamrequest = StreamRequest {
id: req.path,
container: Container::new("photos".tostring()),
chunksize: 4096,
context: None
};
// replace start_download
with blobstore::default().start_download
match startdownload(streamrequest) {
Ok() => Ok(http::Response::ok()),
Err() => Err("Failed to initiate download of chunk".into())
}
}
/// Handle the incoming chunk as a poem "verse" and log the result /// Note that these chunks can be received out of order, so the poem /// in this case might be displayed in a different order. fn handlechunk(chunk: FileChunk) -> HandlerResult<()> { let verse = String::fromutf8(chunk.chunkbytes)?; info!("Poem {} part {}:\n{}", chunk.id, chunk.sequenceno, verse); Ok(()) }
fn health(: actorcore::HealthCheckRequest) -> HandlerResult
}
```