OneDrive
OneDrive services support.
Capabilities
This service can be used to:
- read
- write
- list
- copy
- rename
-
presign - blocking
Notes
Currently, only OneDrive Personal is supported.
Configuration
access_token
: set the access_token for Graph APIroot
: Set the work directory for backend
You can refer to [OnedriveBuilder
]'s docs for more information
Example
Via Builder
use anyhow::Result;
use opendal::services::Onedrive;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
// create backend builder
let mut builder = Onedrive::default();
builder.access_token("xxx").root("/path/to/root");
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("root".to_string(), "/path/to/dir".to_string());
map.insert("access_token".to_string(), "your_access_token".to_string());
let op: Operator = Operator::via_map(Scheme::Onedrive, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("onedrive", {
root: "/path/to/dir",
access_token: "your_access_token",
});
}
import opendal
op = opendal.Operator("onedrive",
root="/path/to/dir",
access_token="your_access_token",
)