Home

Copy an existing file

Copies an existing file to a new path in the same bucket.

  • RLS policy permissions required:
    • buckets table permissions: none
    • objects table permissions: insert and select
  • Refer to the Storage guide on how access control works
Parameters
  • fromPath
    REQUIRED
    string

    The original file path, including the current file name. For example `folder/image.png`.

  • toPath
    REQUIRED
    string

    The new file path, including the new file name. For example `folder/image-copy.png`.


const { data, error } = await supabase
  .storage
  .from('avatars')
  .copy('public/avatar1.png', 'private/avatar2.png')