remi-gridfs

Crates.ioremi-gridfs
lib.rsremi-gridfs
version
sourcesrc
created_at2023-02-09 05:00:48.916581
updated_at2024-12-04 02:28:07.477829
description๐Ÿปโ€โ„๏ธ๐Ÿงถ Official and maintained remi-rs crate for support of MongoDB GridFS
homepage
repositoryhttps://github.com/Noelware/remi-rs
max_upload_size
id780496
Cargo.toml error:TOML parse error at line 22, column 1 | 22 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
remi-rs (github:noelware:remi-rs)

documentation

README

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

v0.10.0 | ๐Ÿ“œ Documentation
Crate Features Description Enabled by default?
export-crates Exports all the used MongoDB crates as a module called mongodb Yes.
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());
}
Commit count: 249

cargo fmt