supabase-rb-rb
Storage

Copy an existing file

Copy an object to a new path inside the same bucket.

Duplicate an object from from_path to to_path inside the same bucket. The source object is left in place. Cross-bucket copies are not supported by this endpoint.

Signature

supabase.storage.from(bucket_id).copy(from_path, to_path)

Parameters

NameTypeRequiredDescription
from_pathStringRequiredSource object path within the bucket. Sent as sourceKey.
to_pathStringRequiredDestination object path within the same bucket. Sent as destinationKey.

Returns

Returns
Hash

Raw response body from storage-api, typically { "Key" => "<bucket>/<to_path>" } (the new object's full key). Not wrapped in a Struct.

Example — duplicate an object

supabase.storage.from("templates").copy(
  "invoice-blank.pdf",
  "invoice-blank-2026.pdf"
)

Example — snapshot before edit

src = "drafts/post.md"
supabase.storage.from("blog").copy(src, "drafts/post.snapshot-#{Time.now.to_i}.md")
# now safe to mutate src in place

Sends { bucketId, sourceKey, destinationKey } to POST /object/copy. Same-bucket-only restriction.

On this page