mirror of
https://github.com/supabase/supabase.git
synced 2026-07-04 23:14:28 +08:00
81 lines
1.8 KiB
Plaintext
81 lines
1.8 KiB
Plaintext
---
|
|
id: storage-from-copy
|
|
title: 'from.copy()'
|
|
slug: /storage-from-copy
|
|
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs'
|
|
import TabItem from '@theme/TabItem'
|
|
|
|
Copies an existing file to a new path in the same bucket.
|
|
|
|
```js
|
|
const { data, error } = await supabase.storage
|
|
.from('avatars')
|
|
.copy('public/avatar1.png', 'private/avatar2.png')
|
|
```
|
|
|
|
## Parameters
|
|
|
|
<ul className="method-list-group">
|
|
|
|
<li className="method-list-item">
|
|
<h4 className="method-list-item-label">
|
|
<span className="method-list-item-label-name">
|
|
fromPath
|
|
</span>
|
|
<span className="method-list-item-label-badge required">
|
|
required
|
|
</span>
|
|
<span className="method-list-item-validation">
|
|
<code>string</code>
|
|
</span>
|
|
</h4>
|
|
<div class="method-list-item-description">
|
|
|
|
The original file path, including the current file name. For example `folder/image.png`.
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li className="method-list-item">
|
|
<h4 className="method-list-item-label">
|
|
<span className="method-list-item-label-name">
|
|
toPath
|
|
</span>
|
|
<span className="method-list-item-label-badge required">
|
|
required
|
|
</span>
|
|
<span className="method-list-item-validation">
|
|
<code>string</code>
|
|
</span>
|
|
</h4>
|
|
<div class="method-list-item-description">
|
|
|
|
The new file path, including the new file name. For example `folder/image-copy.png`.
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
## Notes
|
|
|
|
- RLS policy permissions required:
|
|
- `buckets` table permissions: none
|
|
- `objects` table permissions: `insert` and `select`
|
|
- Refer to the [Storage guide](/docs/guides/storage#access-control) on how access control works
|
|
|
|
## Examples
|
|
|
|
### Copy file
|
|
|
|
```js
|
|
const { data, error } = await supabase.storage
|
|
.from('avatars')
|
|
.copy('public/avatar1.png', 'private/avatar2.png')
|
|
```
|