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.
βοΈSetup
Initialize the ObitoX client with your Supabase credentials
1import ObitoX from '@obitox/upload';23const client = new ObitoX({4 apiKey: process.env.OBITOX_API_KEY,5 apiSecret: process.env.OBITOX_API_SECRET6});78const supabase = client.supabase({9 url: 'https://your-project.supabase.co',10 token: process.env.SUPABASE_SERVICE_ROLE_KEY,11 bucket: 'avatars'12});
Operations
Upload Features
π€Public Bucket Upload
1const fileUrl = await supabase.upload(file, {2 filename: 'photo.jpg'3});45console.log(fileUrl); // https://...supabase.co/storage/v1/object/public/avatars/photo.jpg
πProgress Tracking
Monitor upload progress in real-time
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
1const supabasePrivate = client.supabase({2 url: process.env.SUPABASE_URL,3 token: process.env.SUPABASE_KEY,4 bucket: 'private-docs'5});67const signedUrl = await supabasePrivate.upload(file, {8 filename: 'contract.pdf'9});10// Returns signed URL
β With File Validation
Server-side validation with Magic Bytes
1const url = await supabase.upload(file, {2 filename: 'photo.jpg',3 validation: 'images'4});
Validation presets: 'images' | 'documents'
Delete
ποΈDelete File
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).
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
1// Get signed URL for download2const { downloadUrl } = await supabase.download({3 filename: 'photo.jpg',4 expiresIn: 3600 // 1 hour5});6console.log(downloadUrl);
List Buckets
πList All Buckets
1const buckets = await supabase.listBuckets();2buckets.forEach(b => console.log(b.name));
Webhooks
Get notified when uploads complete.
β‘Auto Trigger
Server confirms automatically
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
1const url = await supabase.upload(file, {2 filename: 'invoice.jpg',3 webhook: {4 url: 'https://myapp.com/webhooks/upload',5 trigger: 'manual',6 autoConfirm: false7 }8});9// Call confirm endpoint later
Upload Cancellation
πCancel Upload
1const abortController = new AbortController();23try {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.