from.update()

Replaces an existing file at the specified path with a new one.

const avatarFile = event.target.files[0]
const { data, error } = await supabase
.storage
.from('avatars')
.update('public/avatar1.png', avatarFile)

Parameters

  • pathrequiredstring

    The relative file path including the bucket ID. Should be of the format bucket/folder/subfolder. The bucket already exist before attempting to upload.

  • filerequiredFile

    The file object to be stored in the bucket.

  • fileOptionsoptionalFileOptions

    HTTP headers. For example cacheControl

Notes

  • Policy permissions required:
    • buckets permissions: none
    • objects permissions: update and select

Examples

Update file

const avatarFile = event.target.files[0]
const { data, error } = await supabase
.storage
.from('avatars')
.update('public/avatar1.png', avatarFile)