#nft #upload #storage #file-upload #storage-service #download #encryption

nft_storage_core

A Rust client tailored for NFT.storage, providing an intuitive API wrapper for enhanced interaction with the service. It supports storing ERC-1155 compatible NFTs, encrypted file uploads with pluggable encryption modules, asset management, and decentralized identity (DID) handling. The client also enables encrypted downloads and decryption, ensuring secure data handling. It's designed with async capabilities to integrate smoothly into contemporary Rust async ecosystems.

2 unstable releases

0.2.0 Dec 25, 2023
0.1.0 Nov 3, 2023

#37 in #storage-service

41 downloads per month
Used in nft_storage_cli

MIT license

3.5MB
2.5K SLoC

nft.storage-rs

Crates.io Documentation Build Status

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

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Dependencies

~7–20MB
~304K SLoC