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

106 lines
2.4 KiB
Plaintext

---
id: storage-createbucket
title: 'createBucket()'
slug: /storage-createbucket
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 new Storage bucket
```js
const { data, error } = await supabase.storage.createBucket('avatars', {
public: false,
})
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
id
</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">
A unique identifier for the bucket you are creating.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
public
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
The visibility of the bucket. Public buckets don't require an authorization token to download objects, but still require a valid token for all other operations. By default, buckets are private.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- RLS policy permissions required:
- `buckets` table permissions: `insert`
- `objects` table permissions: none
- Refer to the [Storage guide](/docs/guides/storage#access-control) on how access control works
## Examples
### Create bucket
```js
const { data, error } = await supabase.storage.createBucket('avatars', {
public: false,
})
```