Skip to main content

OneDrive

OneDrive services support.

Capabilities

This service can be used to:

  • read
  • write
  • list
  • copy
  • rename
  • scan
  • presign
  • blocking

Notes

Currently, only OneDrive Personal is supported.

Configuration

  • access_token: set the access_token for Graph API
  • root: 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

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(())
}