Capabilities

This service can be used to:

  • [ ] create_dir
  • [x] stat
  • [x] read
  • [x] write
  • [x] delete
  • [x] list
  • [x] copy
  • [ ] rename
  • [x] presign

Configuration

  • root: Set the work directory for backend
  • bucket: Set the container name for backend
  • endpoint: Customizable endpoint setting
  • access_key_id: Set the access_key_id for backend.
  • secret_access_key: Set the secret_access_key for backend.

You can refer to [CosBuilder]'s docs for more information

Example

Via Builder

use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_cos::Cos;

#[tokio::main]
async fn main() -> Result<()> {
    // create backend builder
    let mut builder = Cos::default()
        // set the storage bucket for OpenDAL
        .bucket("test")
        // set the endpoint for OpenDAL
        .endpoint("https://cos.ap-singapore.myqcloud.com")
        // Set the access_key_id and secret_access_key.
        //
        // OpenDAL will try load credential from the env.
        // If credential not set and no valid credential in env, OpenDAL will
        // send request without signing like anonymous user.
        .secret_id("secret_id")
        .secret_key("secret_access_key");

    let op: Operator = Operator::new(builder)?.finish();

    Ok(())
}