Open Data Access Layer that connect the whole world together.
You may be looking for:
OpenDAL is in alpha stage and has been early adopted by databend. Welcome any feedback at Discussions!
- azblob: Azure Storage Blob services.
- fs: POSIX alike file system.
- memory: In memory backend.
- s3: AWS S3 alike services.
use anyhow::Result;
use futures::StreamExt;
use opendal::services::fs;
use opendal::ObjectMode;
use opendal::Operator;
use opendal::Metadata;
use opendal::Object;
use opendal::ObjectStreamer;
#[tokio::main]
async fn main() -> Result<()> {
// Init Operator
let op = Operator::new(fs::Backend::build().root("/tmp").finish().await?);
// Create object handler.
let o: Object = op.object("test_file");
// Write data info object;
let _: () = o.write("Hello, World!").await?;
// Read data from object;
let bs: Vec<u8> = o.read().await?;
// Read range from object;
let bs: Vec<u8> = o.range_read(1..=11).await?;
// Get object's Metadata
let meta: Metadata = o.metadata().await?;
let path: &str = meta.path();
let mode: ObjectMode = meta.mode();
let length: u64 = meta.content_length();
let content_md5: Option<String> = meta.content_md5();
// Delete object.
let _: () = o.delete().await?;
// List dir object.
let o: Object = op.object("test_dir/");
let mut obs: ObjectStreamer = o.list().await?;
while let Some(entry) = obs.next().await {
let entry: Object = entry?;
}
Ok(())
}
More examples could be found at examples.
Check out the CONTRIBUTING.md guide for more details on getting started with contributing to this project.
Submit issues for bug report or asking questions in discussion.
Licensed under Apache License, Version 2.0.