IPFS
IPFS file system support based on IPFS HTTP Gateway.
Capabilities
This service can be used to:
- stat
- read
-
write -
create_dir -
delete -
copy -
rename - list
- presign
- blocking
Configuration
root
: Set the work directory for backendendpoint
: Customizable endpoint setting
You can refer to [IpfsBuilder
]'s docs for more information
Example
Via Builder
use anyhow::Result;
use opendal::services::Ipfs;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
// create backend builder
let mut builder = Ipfs::default();
// set the endpoint for OpenDAL
builder.endpoint("https://ipfs.io");
// set the root for OpenDAL
builder.root("/ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ");
let op: Operator = 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("endpoint".to_string(), "https://ipfs.io".to_string());
map.insert("root".to_string(), "/ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ".to_string());
let op: Operator = Operator::via_map(Scheme::Ipfs, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("ipfs", {
endpoint: "https://ipfs.io",
root: "/ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ",
});
}
import opendal
op = opendal.Operator("ipfs",
endpoint="https://ipfs.io",
root="/ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ",
)