geckopanda

Crates.iogeckopanda
lib.rsgeckopanda
version0.2.0
sourcesrc
created_at2023-08-29 07:06:48.594783
updated_at2023-11-24 16:37:46.122056
descriptionSave and load files from local disk, Google Drive, or Amazon S3.
homepage
repositoryhttps://github.com/ArielHorwitz/geckopanda
max_upload_size
id957728
size81,557
Ariel Horwitz (ArielHorwitz)

documentation

https://docs.rs/geckopanda/0.2.0/geckopanda

README

Crate Docs License

GeckoPanda

Save and load files from local disk, Google Drive, or Amazon S3.

  • ❌ Fast
  • ❌ Smart
  • ✅ Simple

This crate provides the Storage trait and several backends that implement it, providing a very simple API for listing, creating, updating, and deleting files. These operations can be done either asynchronously or syncronously (blocking).

Usage

use geckopanda::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let storage = LocalDiskStorage::new("./storagecache")?;
    // See examples for `GoogleDriveStorage` and `AmazonS3Storage`

    let file_id = storage.create_blocking("example.file")?;
    println!("Created file ID: {file_id}");

    let data = "example file content";
    storage.update_blocking(&file_id, data.as_bytes())?;
    println!("Uploaded data: {data:?}");

    let download_data = String::from_utf8(storage.get_blocking(&file_id)?)?;
    assert_eq!(data, &download_data);
    println!("Downloaded data: {download_data:?}");

    let total_size: u64 = storage
        .list_blocking()?
        .iter()
        .map(|metadata| metadata.size)
        .sum();
    println!("Total size: {total_size} bytes");

    storage.delete_blocking(&file_id)?;
    println!("Deleted file ID: {file_id}");
    Ok(())
}
Commit count: 35

cargo fmt