Skip to content
v2.7

Create bucket

Create a new storage bucket.

POST/storage/bucketsScope buckets.write

SDK: @owbase/node only

Create a new storage bucket.

bucketId string required

Unique Id. Choose a custom ID or generate a random ID with ID.unique(). Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

name string required

Bucket name

permissions string[]

An array of permission strings. By default, no user is granted with any permissions. Learn more about permissions.

fileSecurity boolean

Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. Learn more about permissions.

enabled boolean

Is bucket enabled? When set to ‘disabled’, users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled.

maximumFileSize number

Maximum file size allowed in bytes. Maximum allowed value is 0B.

allowedFileExtensions string[]

Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.

compression Compression

Compression algorithm chosen for compression. Can be one of none, gzip, or zstd, For file size above 20MB compression is skipped even if it’s enabled Values: none, gzip, zstd.

encryption boolean

Is encryption enabled? For file size above 20MB encryption is skipped even if it’s enabled

antivirus boolean

Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it’s enabled

transformations boolean

Are image transformations enabled?

description string

Optional description for the bucket.

stripMetadata boolean

Remove metadata such as location, device and capture time from uploaded images. The color profile and orientation are kept. For file size above 20MB metadata is not removed even if it’s enabled.

Access: API key with the buckets.write scope.

201Success
400Invalid or missing parameter
401No session, no permission on the resource or key without the scope
429Rate limit

Every error comes as JSON with code, type and message: see Errors.

import { Client, Storage, Permission, Role, Compression } from '@owbase/node';
const client = new Client()
.setEndpoint('https://cloud.owbase.dev/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new Storage(client);
const result = await storage.createBucket({
bucketId: '<BUCKET_ID>',
name: '<NAME>',
permissions: [Permission.read(Role.any())], // optional
fileSecurity: false, // optional
enabled: false, // optional
maximumFileSize: 1, // optional
allowedFileExtensions: [], // optional
compression: Compression.None, // optional
encryption: false, // optional
antivirus: false, // optional
transformations: false, // optional
description: '<DESCRIPTION>', // optional
stripMetadata: false, // optional
});
Response201 Created
{
"$id": "5e5ea5c16897e",
"$createdAt": "2020-10-15T06:38:00.000+00:00",
"$updatedAt": "2020-10-15T06:38:00.000+00:00",
"$permissions": [
"read(\"any\")"
],
"fileSecurity": true,
"name": "Documents",
"description": "Invoices and receipts uploaded by customers.",
"enabled": false,
"maximumFileSize": 100,
"allowedFileExtensions": [
"jpg",
"png"
],
"compression": "gzip",
"encryption": false,
"antivirus": false,
"transformations": false,
"stripMetadata": true,
"totalSize": 128
}

The descriptions on this page come from the server API specification (BSD-3-Clause license), and the examples come from the SDK generator (MIT license). The full notices are in the NOTICE file of the @owbase/web and @owbase/node packages.

Was this page helpful?