from.copy()

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

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

Parameters#

  • fromPathrequired
    string

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

  • toPathrequired
    string

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

Notes#

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

Examples#

Copy file#

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