On this page

Storage

Upload, download, list and link to files, and manage buckets.

#upload and getPublicUrl

JavaScript
const file = event.target.files[0]
const { data, error } = await stitchdb.storage
  .from('avatars')
  .upload(`${user.id}/avatar.png`, file, { upsert: true })

const { data: { publicUrl } } = stitchdb.storage.from('avatars').getPublicUrl(data.path)

#download

JavaScript
const { data } = await stitchdb.storage.from('avatars').download('path/avatar.png')

#list, move, copy, remove

JavaScript
await stitchdb.storage.from('avatars').list('folder')
await stitchdb.storage.from('avatars').move('a.png', 'b.png')
await stitchdb.storage.from('avatars').copy('a.png', 'c.png')
await stitchdb.storage.from('avatars').remove(['b.png', 'c.png'])
await stitchdb.storage.from('avatars').info('a.png')
await stitchdb.storage.from('avatars').exists('a.png')

#createSignedUrl

JavaScript
// Private buckets: create a temporary link (expires in 60 seconds)
const { data: signed } = await stitchdb.storage.from('invoices').createSignedUrl('2026/10.pdf', 60)

Also createSignedUrls, createSignedUploadUrl and uploadToSignedUrl; see Signed URLs.

#Buckets

Requires the service_role key:

JavaScript
const admin = createClient('https://<project-ref>.p.stitchdb.com', '<service-role-key>')
await admin.storage.createBucket('avatars', { public: true, fileSizeLimit: '2MB', allowedMimeTypes: ['image/*'] })
await admin.storage.listBuckets()
await admin.storage.getBucket('avatars')
await admin.storage.updateBucket('avatars', { public: false })
await admin.storage.emptyBucket('avatars')
await admin.storage.deleteBucket('avatars')
Was this helpful?