Crate object_store_opendal
source ·Expand description
object_store_opendal is an object store implementation using opendal.
This crate can help you to access 30 more storage services with the same object_store API.
use std::sync::Arc;
use bytes::Bytes;
use object_store::path::Path;
use object_store::ObjectStore;
use object_store_opendal::OpendalStore;
use opendal::services::S3;
use opendal::{Builder, Operator};
#[tokio::main]
async fn main() {
let builder = S3::from_map(
vec![
("access_key".to_string(), "my_access_key".to_string()),
("secret_key".to_string(), "my_secret_key".to_string()),
("endpoint".to_string(), "my_endpoint".to_string()),
("region".to_string(), "my_region".to_string()),
]
.into_iter()
.collect(),
);
// Create a new operator
let operator = Operator::new(builder).unwrap().finish();
// Create a new object store
let object_store = Arc::new(OpendalStore::new(operator));
let path = Path::from("data/nested/test.txt");
let bytes = Bytes::from_static(b"hello, world! I am nested.");
object_store.put(&path, bytes.clone().into()).await.unwrap();
let content = object_store
.get(&path)
.await
.unwrap()
.bytes()
.await
.unwrap();
assert_eq!(content, bytes);
}
Structs§
- OpendalStore implements ObjectStore trait by using opendal.