-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(unftp-sbe): adds example and readme (#4777)
add example and doc
- Loading branch information
1 parent
b13a78d
commit a7b1a6c
Showing
3 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,54 @@ | ||
# Apache OpenDAL™ unftp Integration | ||
|
||
This crate intends to build an backend based on OpenDAL for [unftp](https://crates.io/crates/unftp). | ||
`unftp-sbe-opendal` is an [unftp](https://crates.io/crates/unftp) `StorageBackend` implementation using opendal. | ||
|
||
This crate can help you to access ANY storage services with the same ftp API. | ||
|
||
## Examples | ||
|
||
```rust | ||
use anyhow::Result; | ||
use opendal::Operator; | ||
use unftp_sbe_opendal::OpendalStorage; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// Create any service desired | ||
let service = opendal::services::S3::from_map( | ||
[ | ||
("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(), | ||
); | ||
|
||
// Init an operator with the service created | ||
let op = Operator::new(service)?.finish(); | ||
|
||
// Wrap the operator with `OpendalStorage` | ||
let backend = OpendalStorage::new(op); | ||
|
||
// Build the actual unftp server | ||
let server = libunftp::ServerBuilder::new(Box::new(move || backend.clone())).build()?; | ||
|
||
// Start the server | ||
server.listen("0.0.0.0:0").await?; | ||
|
||
Ok(()) | ||
} | ||
``` | ||
|
||
## Branding | ||
|
||
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](https://www.apache.org/foundation/marks/guide). | ||
|
||
## License and Trademarks | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::error::Error; | ||
|
||
use opendal::Operator; | ||
use unftp_sbe_opendal::OpendalStorage; | ||
|
||
#[tokio::main(flavor = "current_thread")] | ||
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> { | ||
// Create any service desired | ||
let service = opendal::services::Memory::default(); | ||
|
||
// Init an operator with the service created | ||
let op = Operator::new(service)?.finish(); | ||
|
||
// Wrap the operator with `OpendalStorage` | ||
let backend = OpendalStorage::new(op); | ||
|
||
// Build the actual unftp server | ||
let server = libunftp::ServerBuilder::new(Box::new(move || backend.clone())).build()?; | ||
|
||
// Start the server | ||
server.listen("0.0.0.0:0").await?; | ||
|
||
Ok(()) | ||
} |