2 unstable releases
0.2.0 | Dec 25, 2023 |
---|---|
0.1.0 | Nov 3, 2023 |
#46 in #storage-service
Used in nft_storage_cli
3.5MB
2.5K
SLoC
nft.storage-rs
nft.storage-rs
is a Rust client for easily uploading a file to the nft.storage service.
Features
- Upload a File, Directory, or JSON object
Installation
Add the following to your Cargo.toml
:
[dependencies]
nft.storage-rs = "0.1.0"
Run:
$ cargo build
Usage
Here's a quick example:
use std::path::PathBuf;
use nft_storage_core::{encryptor::plugins::aes::AesEncryptor, NftStorageApi, NftStorageCore};
#[tokio::main]
async fn main() {
let aes = AesEncryptor::generate_key().unwrap();
let encryptor = Box::new(aes);
// If pass none, use NFT_STORAGE_API_KEY envrioment variable.
let api_key = Some("<FILL ME NFT_STORAGE_API_KEY>".to_string());
let client = NftStorageCore::try_new(api_key, encryptor).unwrap();
let path = vec![PathBuf::from("test.txt")];
let resp = client.upload(&path, None).await.unwrap();
println!("{}", serde_json::to_string_pretty(&resp).unwrap());
}
For more examples, please refer to the examples/
directory.
Documentation
For full documentation, please visit docs.rs/nft.storage-rs.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Dependencies
~8–20MB
~292K SLoC