pub struct StorageClient { /* private fields */ }Expand description
HTTP client for Supabase Storage API.
Communicates with Storage REST endpoints at /storage/v1/....
§Example
ⓘ
use supabase_client_storage::StorageClient;
let storage = StorageClient::new("https://your-project.supabase.co", "your-anon-key")?;
let buckets = storage.list_buckets().await?;
let file_api = storage.from("avatars");Implementations§
Source§impl StorageClient
impl StorageClient
Sourcepub fn new(supabase_url: &str, api_key: &str) -> Result<Self, StorageError>
pub fn new(supabase_url: &str, api_key: &str) -> Result<Self, StorageError>
Create a new storage client.
supabase_url is the project URL (e.g., https://your-project.supabase.co).
api_key is the Supabase anon or service_role key.
Sourcepub async fn list_buckets(&self) -> Result<Vec<Bucket>, StorageError>
pub async fn list_buckets(&self) -> Result<Vec<Bucket>, StorageError>
List all buckets.
Sourcepub async fn get_bucket(&self, id: &str) -> Result<Bucket, StorageError>
pub async fn get_bucket(&self, id: &str) -> Result<Bucket, StorageError>
Get a bucket by ID.
Sourcepub async fn create_bucket(
&self,
id: &str,
options: BucketOptions,
) -> Result<CreateBucketResponse, StorageError>
pub async fn create_bucket( &self, id: &str, options: BucketOptions, ) -> Result<CreateBucketResponse, StorageError>
Create a new bucket.
Sourcepub async fn update_bucket(
&self,
id: &str,
options: BucketOptions,
) -> Result<(), StorageError>
pub async fn update_bucket( &self, id: &str, options: BucketOptions, ) -> Result<(), StorageError>
Update a bucket.
Sourcepub async fn empty_bucket(&self, id: &str) -> Result<(), StorageError>
pub async fn empty_bucket(&self, id: &str) -> Result<(), StorageError>
Empty a bucket (remove all files).
Sourcepub async fn delete_bucket(&self, id: &str) -> Result<(), StorageError>
pub async fn delete_bucket(&self, id: &str) -> Result<(), StorageError>
Delete a bucket. The bucket must be empty first.
Sourcepub fn from(&self, bucket: &str) -> StorageBucketApi
pub fn from(&self, bucket: &str) -> StorageBucketApi
Create a file operations API scoped to a bucket.
Mirrors supabase.storage.from('bucket').
Trait Implementations§
Source§impl Clone for StorageClient
impl Clone for StorageClient
Source§fn clone(&self) -> StorageClient
fn clone(&self) -> StorageClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StorageClient
impl !RefUnwindSafe for StorageClient
impl Send for StorageClient
impl Sync for StorageClient
impl Unpin for StorageClient
impl UnsafeUnpin for StorageClient
impl !UnwindSafe for StorageClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more