Supabase Storage
This is a Rust implementation of the supabase storage client. The goal is to have feature parity and an easy-to-use API.
Currently this software is functional, but not yet battle-tested.
Installation
Cargo
Usage
Create a Storage Client
// You can manually pass in the values
let auth_client = new.unwrap;
// Or you can use environment variables
// Requires `SUPABASE_URL` and`SUPABASE_API_KEY` environment variables
let auth_client = new_from_env.unwrap;
Create a Bucket
Create a new storage bucket. Returns the bucket name (not ID) on success.
let name = client
.create_bucket
.await
.unwrap;
Delete a Bucket
client.delete_bucket.await.unwrap;
Update a Bucket
client
.update_bucket
.await
.unwrap;
Get a Bucket
let bucket = client.get_bucket.await.unwrap;
// Returns a `Bucket`
List Files in a Bucket
let options = FileSearchOptions ;
client
.list_files
.await
.unwrap;
List Buckets
let buckets = client.list_buckets.await.unwrap;
Empty a Bucket
let empty = client.empty_bucket.await.unwrap;
Upload a File
let object = client
.upload_file
.await
.unwrap;
Update a File
let object = client
.update_file
.await
.unwrap;
Download a File
let file = client
.download_file
.await
.unwrap;
Copy a File
// Copy within same bucket, including metadata
let key = client
.copy_file
.await
.unwrap;
// Copy between different buckets
let key = client
.copy_file
.await
.unwrap;
Delete a File
let message = client
.delete_file
.await
.unwrap;
Create a Signed URL
let signed_url = client
.create_signed_url
.await
.unwrap;
Create Multiple Signed URLs
let urls = client
.create_multiple_signed_urls
.await
.unwrap;
Create a Signed Upload URL
Returns SignedUploadUrlResponse containing:
url
: Path without hostname
token
: Authorization token
let signed = client
.create_signed_upload_url
.await
.unwrap;
Upload to a Signed URL
let object = client
.upload_to_signed_url
.await
.unwrap;
Get Public URL
// Basic usage
let url = client
.get_public_url
.await
.unwrap;
// With image transformation
let options = DownloadOptions ;
let url = client
.get_public_url
.await
.unwrap;
Features
- Create Bucket
- Delete Bucket
- Update Buckets
- Get Bucket
- List Buckets
- Empty Bucket
- Upload a file
- Update a file
- Download a file
- List files in a bucket
- Replace a file in a bucket
- Move a file in a bucket
- Copy a file in a bucket
- Delete files in a bucket
- Create signed URL
- Create multiple signed URLs
- Create signed upload URLs
- Upload to a signed URL
- Retrieve public URL
Contributions
Contributors are always welcome. I only ask that you add or update tests to cover your changes. Until this crate reaches 1.0.0 we're in the "move fast and break things" phase. Don't concern yourself with elegance.