Gridfs
Gridfs services support.
Capabilities
This service can be used to:
- stat
- read
- write
- create_dir
- delete
- copy
- rename
-
list -
presign - blocking
Configuration
root
: Set the working directory ofOpenDAL
connection_string
: Set the connection string of mongodb serverdatabase
: Set the database of mongodbbucket
: Set the bucket of mongodb gridfschunk_size
: Set the chunk size of mongodb gridfs
Example
Via Builder
use anyhow::Result;
use opendal::services::Gridfs;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Gridfs::default();
builder.root("/");
builder.connection_string("mongodb://myUser:myPassword@localhost:27017/myAuthDB");
builder.database("your_database");
builder.bucket("your_bucket");
// The chunk size in bytes used to break the user file into chunks.
builder.chunk_size(255);
let op = Operator::new(builder)?.finish();
Ok(())
}
Via Config
- Rust
- Node.js
- Python
use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("connection_string".to_string(), "connection_string".to_string());
map.insert("database".to_string(), "database".to_string());
map.insert("bucket".to_string(), "bucket".to_string());
let op: Operator = Operator::via_map(Scheme::Gridfs, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const config = {
connection_string: "connection_string",
database: "database",
bucket: "bucket",
};
const op = new Operator("gridfs", config);
}
import opendal
config = {
"connection_string": "connection_string",
"database": "database",
"bucket": "bucket",
}
op = opendal.Operator("gridfs", **config)