JavaScript: Replace an existing file

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

Parameters

Examples

Update file

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

Update file using `ArrayBuffer` from base64 file data

import \{decode\} from 'base64-arraybuffer'

const \{ data, error \} = await supabase
  .storage
  .from('avatars')
  .update('public/avatar1.png', decode('base64FileData'), \{
    contentType: 'image/png'
  \})