File Storage¶
The Supabase Storage module implements IFileStore using Supabase Storage, an S3-compatible object store with built-in CDN and access controls.
Overview¶
This registers IFileStore → SupabaseFileStore, backed by the generated SupabaseStorageClient.
Configuration¶
The storage client uses the shared SupabaseOptions for the project URL and service role key. The bucketId parameter (default: "files") selects which storage bucket to use.
Create your bucket in the Supabase dashboard (Storage → New bucket) or via SQL:
Usage¶
Use through IFileStore — the same interface used by Azure Blob, S3, or local filesystem:
// Upload
var metadata = await fileStore.UploadAsync(
"invoices/2024/inv-001.pdf", pdfStream, "application/pdf");
// Generate a time-limited download link
var url = await fileStore.GetPresignedUrlAsync(
metadata.Key, TimeSpan.FromMinutes(15));
// Check existence
var exists = await fileStore.ExistsAsync("invoices/2024/inv-001.pdf");
// Download
await using var stream = await fileStore.DownloadAsync(metadata.Key);
// Delete
await fileStore.DeleteAsync(metadata.Key);
Interface¶
IFileStore is the same interface documented in File Storage:
| Method | Returns | Description |
|---|---|---|
UploadAsync(key, content, contentType) |
Task<FileMetadata> |
Upload a file |
DownloadAsync(key) |
Task<Stream> |
Download a file |
DeleteAsync(key) |
Task |
Delete a file |
ExistsAsync(key) |
Task<bool> |
Check if a file exists |
GetMetadataAsync(key) |
Task<FileMetadata?> |
Get file metadata |
GetPresignedUrlAsync(key, expiry) |
Task<string> |
Generate a signed URL |
Swapping Providers¶
Since SupabaseFileStore implements the standard IFileStore interface, you can swap between providers without changing application code:
// Development — local filesystem
options.AddLocalFileStore("./uploads");
// Production — Supabase Storage
options.AddSupabaseFileStore(bucketId: "uploads");
// Alternative — Azure Blob
options.AddAzureBlobFileStore();
ISupabaseStorage Effects¶
For Supabase-specific storage operations beyond IFileStore — bucket management, signed upload URLs, move/copy — use SupabaseStorageModule:
Register the implementation:
Then compose storage operations as effects:
public static Eff<AppRuntime, string> UploadAndSign(string bucket, string path, Stream content) =>
from _ in AppEffects.Storage.UploadAsync<AppRuntime>(path, content, "application/octet-stream")
from url in AppEffects.SupabaseStorage.CreateSignedUrlAsync<AppRuntime>(bucket, path, 3600)
select url;
Available Operations¶
| Effect Method | Description |
|---|---|
ListBucketsAsync |
List all storage buckets |
GetBucketAsync |
Get bucket details by ID |
CreateBucketAsync |
Create a new storage bucket |
EmptyBucketAsync |
Remove all files from a bucket |
DeleteBucketAsync |
Delete a bucket |
ListFilesAsync |
List files in a bucket path |
MoveFileAsync |
Move a file within or between buckets |
CopyFileAsync |
Copy a file within or between buckets |
CreateSignedUrlAsync |
Generate a time-limited download URL |
CreateSignedUploadUrlAsync |
Generate a time-limited upload URL |
DeleteFilesAsync |
Delete multiple files at once |