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.

JavaScript: copy

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

Parameters

Examples

Copy file

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

Copy file with content encoding

const { data, error } = await supabase
  .storage
  .from('documents')
  .copy('source.txt.gz', 'copy.txt.gz', {
    copyMetadata: false,
    metadata: { contentEncoding: 'gzip' },
  })

The source must already contain gzip-encoded bytes. Copying changes metadata only.