#mongo-db #remi #grid-fs #remi-rs #logging #bear #logging-tracing #storage-config

remi-gridfs

๐Ÿปโ€โ„๏ธ๐Ÿงถ Official and maintained remi-rs crate for support of MongoDB GridFS

22 releases

0.10.2 Apr 30, 2025
0.10.1 Jan 13, 2025
0.10.0 Dec 4, 2024
0.9.1 Oct 21, 2024
0.1.0 Feb 9, 2023

#2001 in Database interfaces

Download history 223/week @ 2025-07-01 170/week @ 2025-07-08 94/week @ 2025-07-15 101/week @ 2025-07-22 116/week @ 2025-07-29 243/week @ 2025-08-05 118/week @ 2025-08-12 118/week @ 2025-08-19 63/week @ 2025-08-26 79/week @ 2025-09-02 70/week @ 2025-09-09 63/week @ 2025-09-16 18/week @ 2025-09-23 9/week @ 2025-09-30 133/week @ 2025-10-07 49/week @ 2025-10-14

209 downloads per month
Used in 2 crates (via azalia-remi)

MIT license

59KB
588 lines

Official and maintained remi-rs crate for support of MongoDB GridFS

v0.10.1 | ๐Ÿ“œ Documentation
Crate Features Description Enabled by default?
export-crates Exports all the used MongoDB crates as a module called mongodb No.
unstable Tap into unstable features from remi_gridfs and the remi crate. No.
tracing Enables the use of tracing::instrument and emit events for actions by the crate. No.
serde Enables the use of serde in StorageConfig No.
log Emits log records for actions by the crate No.

Example

// Cargo.toml:
//
// [dependencies]
// remi = "^0"
// remi-gridfs = { version = "^0", features = ["export-crates"] }
// tokio = { version = "^1", features = ["full"] }

use remi_gridfs::{StorageService, StorageConfig, mongodb};
use remi::{StorageService as _, UploadRequest};

#[tokio::main]
async fn main() {
    let storage = StorageService::from_conn_string("mongodb://localhost:27017", StorageConfig {
        bucket: "my-bucket".into(),

        ..Default::default()
    }).await.unwrap();

    // Initialize the container. This will:
    //
    // * create the `my-bucket` GridFS bucket if it doesn't exist
    storage.init().await.unwrap();

    // Now we can upload files to GridFS.

    // We define a `UploadRequest`, which will set the content type to `text/plain` and set the
    // contents of `weow.txt` to `weow fluff`.
    let upload = UploadRequest::default()
        .with_content_type(Some("text/plain"))
        .with_data("weow fluff");

    // Let's upload it!
    storage.upload("weow.txt", upload).await.unwrap();

    // Let's check if it exists! This `assert!` will panic if it failed
    // to upload.
    assert!(storage.exists("weow.txt").await.unwrap());
}

Dependencies

~11โ€“24MB
~305K SLoC