Files
supabase/apps/reference/_supabase_js/generated/storage-createbucket.mdx
T
2022-08-18 15:55:39 +08:00

105 lines
2.1 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. By default, buckets are not public.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: `insert`
- `objects` permissions: none
## Examples
### Create bucket
```js
const { data, error } = await supabase.storage.createBucket('avatars', {
public: false,
})
```