ObitoX Docs
Providers
Storage ProviderSQL INTEGRATED

Supabase Storage

Postgres-integrated object storage with RLS

S3-compatible object storage tightly integrated with your PostgreSQL database. Secure your files with Row Level Security (RLS) policies.

How it works

Files are stored in buckets with permissions controlled directly by your database policies.

Your App
Client
Authenticated Request
Upload with Token
ObitoX
SDK
Secure Upload
Supabase
Storage
RLS Protected
SQL Integrated
Signed URLs

βš™οΈSetup

Initialize the ObitoX client with your Supabase credentials

typescript
1import ObitoX from '@obitox/upload';
2
3const client = new ObitoX({
4 apiKey: process.env.OBITOX_API_KEY,
5 apiSecret: process.env.OBITOX_API_SECRET
6});
7
8const supabase = client.supabase({
9 url: 'https://your-project.supabase.co',
10 token: process.env.SUPABASE_SERVICE_ROLE_KEY,
11 bucket: 'avatars'
12});

Upload Features

πŸ“€Public Bucket Upload

typescript
1const fileUrl = await supabase.upload(file, {
2 filename: 'photo.jpg'
3});
4
5console.log(fileUrl); // https://...supabase.co/storage/v1/object/public/avatars/photo.jpg

πŸ“ŠProgress Tracking

Monitor upload progress in real-time

typescript
1const fileUrl = await supabase.upload(file, {
2 filename: 'video.mp4',
3 onProgress: (percent, uploaded, total) => {
4 console.log(`${percent}% β€” ${uploaded}/${total} bytes`);
5 }
6});

πŸ”’Upload to Private Bucket

Generates a signed URL automatically

typescript
1const supabasePrivate = client.supabase({
2 url: process.env.SUPABASE_URL,
3 token: process.env.SUPABASE_KEY,
4 bucket: 'private-docs'
5});
6
7const signedUrl = await supabasePrivate.upload(file, {
8 filename: 'contract.pdf'
9});
10// Returns signed URL

βœ…With File Validation

Server-side validation with Magic Bytes

typescript
1const url = await supabase.upload(file, {
2 filename: 'photo.jpg',
3 validation: 'images'
4});

Validation presets: 'images' | 'documents'

Delete

πŸ—‘οΈDelete File

typescript
1await supabase.delete({
2 fileUrl: 'https://...supabase.co/storage/v1/object/public/avatars/photo.jpg'
3});

Download URL

Generate signed download URLs for files (useful for private buckets).

Note: filename is the uploaded file's key from the URL, not the original name you passed to upload(). Extract it from the upload result.

πŸ”—Generate Signed URL

typescript
1// Get signed URL for download
2const { downloadUrl } = await supabase.download({
3 filename: 'photo.jpg',
4 expiresIn: 3600 // 1 hour
5});
6console.log(downloadUrl);

List Buckets

πŸ“‹List All Buckets

typescript
1const buckets = await supabase.listBuckets();
2buckets.forEach(b => console.log(b.name));

Webhooks

Get notified when uploads complete.

⚑Auto Trigger

Server confirms automatically

typescript
1const url = await supabase.upload(file, {
2 filename: 'report.jpg',
3 webhook: {
4 url: 'https://myapp.com/webhooks/upload',
5 trigger: 'auto'
6 }
7});

πŸ‘†Manual Trigger

You confirm when ready

typescript
1const url = await supabase.upload(file, {
2 filename: 'invoice.jpg',
3 webhook: {
4 url: 'https://myapp.com/webhooks/upload',
5 trigger: 'manual',
6 autoConfirm: false
7 }
8});
9// Call confirm endpoint later

Upload Cancellation

πŸ›‘Cancel Upload

typescript
1const abortController = new AbortController();
2
3try {
4 const uploadPromise = supabase.upload(largeFile, {
5 filename: 'large.jpg',
6 onProgress: (p) => {
7 if (p > 50) abortController.abort();
8 }
9 });
10 await uploadPromise;
11} catch (error) {
12 console.log('Upload cancelled');
13}

That's it!

SQL-integrated storage, one unified API.

Upload securely, manage buckets, and leverage Postgres RLSβ€”automatically.
ObitoX handles the complexity for you.

On this page