Files
supabase/apps/reference/_supabase_js/generated/storage-from-createsignedurl.mdx
2022-08-23 13:05:23 +08:00

81 lines
1.9 KiB
Plaintext

---
id: storage-from-createsignedurl
title: 'from.createSignedUrl()'
slug: /storage-from-createsignedurl
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'
Creates a signed URL. Use a signed URL to share a file for a fixed amount of time.
```js
const { data, error } = await supabase.storage
.from('avatars')
.createSignedUrl('folder/avatar1.png', 60)
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
path
</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 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">
expiresIn
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>number</code>
</span>
</h4>
<div class="method-list-item-description">
The number of seconds until the signed URL expires. For example, `60` for a URL which is valid for one minute.
</div>
</li>
</ul>
## Notes
- RLS policy permissions required:
- `buckets` table permissions: none
- `objects` table permissions: `select`
- Refer to the [Storage guide](/docs/guides/storage#access-control) on how access control works
## Examples
### Create Signed URL
```js
const { data, error } = await supabase.storage
.from('avatars')
.createSignedUrl('folder/avatar1.png', 60)
```