Crates.io | cloud_filter_opendal |
lib.rs | cloud_filter_opendal |
version | 0.0.3 |
source | src |
created_at | 2024-09-11 08:13:27.626959 |
updated_at | 2024-11-07 06:04:39.150301 |
description | Cloud Filter Integration for Apache OpenDAL |
homepage | https://opendal.apache.org/ |
repository | https://github.com/apache/opendal |
max_upload_size | |
id | 1371660 |
size | 92,611 |
cloud_filter_opendal
integrates OpenDAL with cloud sync engines. It provides a way to access various cloud storage on Windows.
Note that cloud_filter_opendal
is a read-only service, and it is not recommended to use it in production.
use anyhow::Result;
use cloud_filter::root::PopulationType;
use cloud_filter::root::SecurityId;
use cloud_filter::root::Session;
use cloud_filter::root::SyncRootIdBuilder;
use cloud_filter::root::SyncRootInfo;
use opendal::services;
use opendal::Operator;
use tokio::runtime::Handle;
use tokio::signal;
#[tokio::main]
async fn main() -> Result<()> {
// Create any service desired
let op = Operator::from_iter::<services::S3>([
("bucket".to_string(), "my_bucket".to_string()),
("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()),
])?
.finish();
let client_path = std::env::var("CLIENT_PATH").expect("$CLIENT_PATH is set");
// Create a sync root id
let sync_root_id = SyncRootIdBuilder::new("cloud_filter_opendal")
.user_security_id(SecurityId::current_user()?)
.build();
// Register the sync root if not exists
if !sync_root_id.is_registered()? {
sync_root_id.register(
SyncRootInfo::default()
.with_display_name("OpenDAL Cloud Filter")
.with_population_type(PopulationType::Full)
.with_icon("shell32.dll,3")
.with_version("1.0.0")
.with_recycle_bin_uri("http://cloudmirror.example.com/recyclebin")?
.with_path(&client_path)?,
)?;
}
let handle = Handle::current();
let connection = Session::new().connect_async(
&client_path,
cloud_filter_opendal::CloudFilter::new(op, client_path.clone().into()),
move |f| handle.block_on(f),
)?;
signal::ctrl_c().await?;
// Drop the connection before unregister the sync root
drop(connection);
sync_root_id.unregister()?;
Ok(())
}
The first and most prominent mentions must use the full form: Apache OpenDALâ„¢ of the name for any individual usage (webpage, handout, slides, etc.) Depending on the context and writing style, you should use the full form of the name sufficiently often to ensure that readers clearly understand the association of both the OpenDAL project and the OpenDAL software product to the ASF as the parent organization.
For more details, see the Apache Product Name Usage Guide.
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
Apache OpenDAL, OpenDAL, and Apache are either registered trademarks or trademarks of the Apache Software Foundation.