Skip to main content

Supabase

Supabase service support.

Capabilities

  • stat
  • read
  • write
  • create_dir
  • delete
  • copy
  • rename
  • list
  • scan
  • presign
  • blocking

Configuration

  • root: Set the work dir for backend.
  • bucket: Set the container name for backend.
  • endpoint: Set the endpoint for backend.
  • key: Set the authorization key for the backend, do not set if you want to read public bucket

Authorization keys

There are two types of key in the Supabase, one is anon_key(Client key), another one is service_role_key(Secret key). The former one can only write public resources while the latter one can access all resources. Note that if you want to read public resources, do not set the key.

Example

Via Builder

use anyhow::Result;
use opendal::services::Supabase;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Supabase::default();

builder.root("/");
builder.bucket("test_bucket");
builder.endpoint("http://127.0.0.1:54321");
// this sets up the anon_key, which means this operator can only write public resource
builder.key("some_anon_key");

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(), "/".to_string());
map.insert("bucket".to_string(), "test_bucket".to_string());
map.insert("endpoint".to_string(), "http://127.0.0.1:54321".to_string());
map.insert("key".to_string(), "some_anon_key".to_string());

let op: Operator = Operator::via_map(Scheme::Supabase, map)?;
Ok(())
}