For AI agents: the documentation index is at llms.txt. Guide pages have a markdown version at the same path with .md appended, before any query string or fragment.
Uploads a file to an existing bucket.
The file path, including the file name. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
The body of the file to be stored in the bucket.
Optional file upload options including cacheControl, contentType, contentEncoding, upsert, and metadata.
const avatarFile = event.target.files[0]
const { data, error } = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', avatarFile, {
cacheControl: '3600',
upsert: false
})
import { decode } from 'base64-arraybuffer'
const { data, error } = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', decode('base64FileData'), {
contentType: 'image/png'
})
const { data, error } = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', avatarFile)
if (error) {
// Log the full error so fields like `statusCode` and `error` (the
// Storage error name, e.g. "Duplicate") aren't hidden behind `error.message`.
console.error(error)
return
}