remi-fs 0.1.1

๐Ÿปโ€โ„๏ธ๐Ÿงถ Local filesystem implementation for remi-rs
Documentation

๐Ÿปโ€โ„๏ธ๐Ÿงถ remi-fs

The remi-fs crate implements the remi-core crate that interacts with the filesystem. This is also re-exported as remi::fs since remi exports this crate by default unless if default-features was false for the remi crate.

remi-fs only supports the Tokio runtime, async-std and other asynchronous rumtimes might be supported in the future.

Features

serde [disabled by default]

Enables the use of serde for the FilesystemStorageConfig struct.

Usage

[dependencies]
bytes = "1.3.0"
remi = { version = "0.1" }
tokio = { version = "1.21", features = ["fs"] }
use remi::filesystem::FilesystemStorageService;
use remi::builders::UploadRequest;
use bytes::Bytes;

async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let fs = FilesystemStorageService::new("./.data");

    // init() will create the directory that was passed above
    // if it doesn't exist on the disk
    fs.init().await?;

    // now, let's open a file that doesn't exist
    let file = fs.open("./owo.txt").await?;
    // "file" will be None since the file doesn't exist on the disk

    // let's create the file
    fs.upload("./owo.txt", UploadRequest::builder()
        .content(Bytes::new())
        .content_type("text/plain")
        .build()?
    ).await?;

    // now, let's read the file again
    let file = fs.open("./owo.txt").await?;
    // "file" is now Some(Blob::File).
}