Storage API
Upload, download, list, and manage files using the Postbase Storage API and SDK.
Storage API
Postbase Storage is an S3-compatible file storage layer built on MinIO (or AWS S3 / Cloudflare R2). It organises files into buckets and objects.
Bucket Endpoints
GET /api/storage/v1/bucket— List all bucketsPOST /api/storage/v1/bucket— Create a bucketGET/PUT/DELETE /api/storage/v1/bucket/:id— Get, update, or delete a bucketPOST /api/storage/v1/bucket/:id/empty— Delete all objects in a bucket
Object Endpoints
POST /api/storage/v1/object/:bucket/:path— Upload (create new)PUT /api/storage/v1/object/:bucket/:path— Upsert (create or overwrite)GET /api/storage/v1/object/:bucket/:path— Download (requires API key)DELETE /api/storage/v1/object/:bucket— Delete multiple objects (body:{"prefixes": [...]})POST /api/storage/v1/object/list/:bucket— List objects with prefix and paginationPOST /api/storage/v1/object/sign/:bucket/:path— Generate a pre-signed URLPOST /api/storage/v1/object/move— Move / rename an objectPOST /api/storage/v1/object/copy— Copy an objectGET /api/storage/v1/object/public/:bucket/:path— Serve a public object (no auth required)
Bucket Options
public: boolean— If true, objects are accessible without authentication via the public endpointallowedMimeTypes: string[]— Restrict uploads to specific MIME typesfileSizeLimit: number— Maximum file size in bytes
SDK Example
// Upload
const { data, error } = await postbase.storage
.from('avatars')
.upload('user-123.png', file, { contentType: 'image/png' })
// Get public URL
const { data: { publicUrl } } = postbase.storage
.from('avatars')
.getPublicUrl('user-123.png')
// List
const { data: files } = await postbase.storage
.from('avatars')
.list('folder/', { limit: 20 })
// Delete
await postbase.storage.from('avatars').remove(['user-123.png'])Pre-signed URLs
const { data } = await postbase.storage
.from('documents')
.createSignedUrl('report.pdf', 3600) // expires in 1 hour
console.log(data.signedUrl)