Storage buckets are a group of files, similar to collections in Appwrite Databases. Buckets let you limit file size and extensions, whether or not to encrypt the files, and more.
Create Bucket
You can create your bucket from the Appwrite Console, a Server SDK, or the CLI.
You can create a bucket by heading to the Storage page and clicking Create bucket.
You can also create collections programmatically using a Server SDK. Appwrite Server SDKs require an API key.
const sdk = require('node-appwrite');
// Init SDK
const client = new sdk.Client();
const storage = new sdk.Storage(client);
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<PROJECT_ID>') // Your project ID
.setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key
;
const promise = storage.createBucket('[BUCKET_ID]', '[NAME]');
promise.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
You can also configure permission, file size and extension restrictions, and more in the createBucket method, learn more about the createBucket in the API references.
Create a bucket using the CLI command appwrite init buckets.
appwrite init buckets
This will initialize your bucket in your appwrite.json file. To push your initialized bucket, use the appwrite push buckets.
appwrite push buckets
This will create your bucket in the Console with all of your appwrite.json configurations.
Learn more about the CLI buckets commands
Permissions
Appwrite uses permissions to control file access. For security, only users that are granted permissions can access a file. This helps prevent accidental data leaks by forcing you to make more concious decisions around permissions.
By default, Appwrite doesn't grants permissions to any users when a new bucket is created. This means users can't create new files or read, update, and delete existing files.
Learn about configuring permissions.
Encryption
Appwrite provides added security settings for your buckets. Enable encryption under your bucket's Settings > Security settings. You can enable encryption to encrypt files in your buckets. If your files are leaked, encrypted files cannot be read by the malicious actor. Files bigger than 20MB cannot be encrypted.
Compression
Appwrite allows you to compress your files. Two algorithms are available, which are gzip and zstd. You can enable compress under your bucket's Settings > Compression. For files larger than 20MB, compression will be skipped even when enabled.
Maximum file size
Limit the maximum file size allowed in the bucket to prevent abuse. You can configure maximum file size under your bucket's Settings > Maximum file size.
File extensions
Limit the file extensions allowed in the bucket to prevent abuse. A maximum of 100 file extensions can be added. Leave blank to allow all file types. You can configure maximum file size under your bucket's Settings > File extensions.