Skip to main content

StorageBucketApi

Struct StorageBucketApi 

Source
pub struct StorageBucketApi { /* private fields */ }
Expand description

File operations API scoped to a specific bucket.

Created via StorageClient::from("bucket_name").

§Example

let file_api = storage.from("avatars");
file_api.upload("photo.png", data, FileOptions::new()).await?;
let bytes = file_api.download("photo.png").await?;

Implementations§

Source§

impl StorageBucketApi

Source

pub async fn upload( &self, path: &str, data: Vec<u8>, options: FileOptions, ) -> Result<UploadResponse, StorageError>

Upload a file to the bucket.

Mirrors supabase.storage.from('bucket').upload(path, file, options).

Source

pub async fn update( &self, path: &str, data: Vec<u8>, options: Option<FileOptions>, ) -> Result<UploadResponse, StorageError>

Update (replace) a file in the bucket.

Mirrors supabase.storage.from('bucket').update(path, file, options).

Source

pub async fn download(&self, path: &str) -> Result<Vec<u8>, StorageError>

Download a file from the bucket.

Returns the raw file bytes.

Source

pub async fn list( &self, path: Option<&str>, options: Option<SearchOptions>, ) -> Result<Vec<FileObject>, StorageError>

List files in the bucket.

path is the folder prefix (e.g., "folder" or None for root).

Source

pub async fn move_file(&self, from: &str, to: &str) -> Result<(), StorageError>

Move a file within the bucket.

Mirrors supabase.storage.from('bucket').move(from, to).

Source

pub async fn copy(&self, from: &str, to: &str) -> Result<String, StorageError>

Copy a file within the bucket.

Returns the key of the new file.

Source

pub async fn remove( &self, paths: Vec<&str>, ) -> Result<Vec<FileObject>, StorageError>

Remove files from the bucket.

Mirrors supabase.storage.from('bucket').remove([paths]).

Source

pub async fn create_signed_url( &self, path: &str, expires_in: u64, ) -> Result<SignedUrlResponse, StorageError>

Create a signed URL for time-limited access to a file.

expires_in is the number of seconds until the URL expires.

Source

pub async fn create_signed_urls( &self, paths: Vec<&str>, expires_in: u64, ) -> Result<Vec<SignedUrlBatchEntry>, StorageError>

Create signed URLs for multiple files.

expires_in is the number of seconds until the URLs expire.

Source

pub fn get_public_url(&self, path: &str) -> String

Get the public URL for a file (no HTTP call, just URL construction).

Only works for files in public buckets.

Source

pub async fn create_signed_upload_url( &self, path: &str, ) -> Result<SignedUploadUrlResponse, StorageError>

Create a signed upload URL for delegated uploads.

Source

pub async fn upload_to_signed_url( &self, token: &str, path: &str, data: Vec<u8>, options: Option<FileOptions>, ) -> Result<(), StorageError>

Upload a file using a previously created signed upload URL.

Source

pub async fn info(&self, path: &str) -> Result<FileInfo, StorageError>

Get file metadata.

Mirrors supabase.storage.from('bucket').info(path).

Source

pub async fn exists(&self, path: &str) -> Result<bool, StorageError>

Check if a file exists.

Mirrors supabase.storage.from('bucket').exists(path). Returns true if the file exists, false if it does not (404).

Source

pub async fn download_with_transform( &self, path: &str, transform: &TransformOptions, ) -> Result<Vec<u8>, StorageError>

Download with server-side image transformation.

Mirrors supabase.storage.from('bucket').download(path, { transform }).

Source

pub fn get_public_url_with_transform( &self, path: &str, transform: &TransformOptions, ) -> String

Get public URL with image transformation (no HTTP call).

Mirrors supabase.storage.from('bucket').getPublicUrl(path, { transform }).

Source

pub async fn create_signed_url_with_transform( &self, path: &str, expires_in: u64, transform: &TransformOptions, ) -> Result<SignedUrlResponse, StorageError>

Create a signed URL with image transformation.

Mirrors supabase.storage.from('bucket').createSignedUrl(path, expiresIn, { transform }).

Source

pub async fn create_signed_urls_with_transform( &self, paths: Vec<&str>, expires_in: u64, transform: &TransformOptions, ) -> Result<Vec<SignedUrlBatchEntry>, StorageError>

Create batch signed URLs with image transformation.

Mirrors supabase.storage.from('bucket').createSignedUrls(paths, expiresIn, { transform }).

Source

pub async fn move_to_bucket( &self, from: &str, to_bucket: &str, to_path: &str, ) -> Result<(), StorageError>

Move a file to a different bucket.

Mirrors supabase.storage.from('bucket').move(from, to, { destinationBucket }).

Source

pub async fn copy_to_bucket( &self, from: &str, to_bucket: &str, to_path: &str, ) -> Result<String, StorageError>

Copy a file to a different bucket.

Returns the key of the new file.

Mirrors supabase.storage.from('bucket').copy(from, to, { destinationBucket }).

Source

pub fn get_public_url_with_download( &self, path: &str, filename: Option<&str>, ) -> String

Get a public URL with optional download disposition.

When filename is Some("file.txt"), appends ?download=file.txt to the URL. When filename is Some(""), appends ?download= (uses original filename).

Mirrors supabase.storage.from('bucket').getPublicUrl(path, { download }).

Source

pub async fn create_signed_url_with_download( &self, path: &str, expires_in: u64, filename: Option<&str>, ) -> Result<SignedUrlResponse, StorageError>

Create a signed URL with optional download disposition.

When filename is Some("file.txt"), appends &download=file.txt to the signed URL. When filename is Some(""), appends &download= (uses original filename).

Mirrors supabase.storage.from('bucket').createSignedUrl(path, expiresIn, { download }).

Source

pub fn bucket_id(&self) -> &str

Get the bucket ID this API is scoped to.

Trait Implementations§

Source§

impl Clone for StorageBucketApi

Source§

fn clone(&self) -> StorageBucketApi

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StorageBucketApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more