The Storage service allows you to manage your project files. Using the Storage service, you can upload, view, download, and query all your project files.
Files are managed using buckets. Storage buckets are similar to Collections we have in our Databases service. The difference is, buckets also provide more power to decide what kinds of files, what sizes you want to allow in that bucket, whether or not to encrypt the files, scan with antivirus and more.
Using Appwrite permissions architecture, you can assign read or write access to each bucket or file in your project for either a specific user, team, user role, or even grant it with public access (any
). You can learn more about how Appwrite handles permissions and access control.
The preview endpoint allows you to generate preview images for your files. Using the preview endpoint, you can also manipulate the resulting image so that it will fit perfectly inside your app in terms of dimensions, file size, and style. The preview endpoint also allows you to change the resulting image file format for better compression or image quality for better delivery over the network.
https://cloud.appwrite.io/v1
List buckets
Get a list of all the storage buckets. You can use the query params to filter your results.
Request
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /storage/buckets
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new sdk.Storage(client);
const result = await storage.listBuckets(
[], // queries (optional)
'<SEARCH>' // search (optional)
);
Create bucket
Create a new storage bucket.
Request
bucketId requiredUnique 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 requiredBucket name
permissions An array of permission strings. By default, no user is granted with any permissions. Learn more about permissions.
fileSecurity 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 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 Maximum file size allowed in bytes. Maximum allowed value is 30MB.
allowedFileExtensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
compression Compression algorithm choosen for compression. Can be one of none, gzip, or zstd, For file size above 20MB compression is skipped even if it's enabled
encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
Response
201
POST /storage/buckets
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new sdk.Storage(client);
const result = await storage.createBucket(
'<BUCKET_ID>', // bucketId
'<NAME>', // name
["read("any")"], // permissions (optional)
false, // fileSecurity (optional)
false, // enabled (optional)
1, // maximumFileSize (optional)
[], // allowedFileExtensions (optional)
sdk..None, // compression (optional)
false, // encryption (optional)
false // antivirus (optional)
);
Get bucket
Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata.
Request
bucketId requiredBucket unique ID.
Response
200
GET /storage/buckets/{bucketId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new sdk.Storage(client);
const result = await storage.getBucket(
'<BUCKET_ID>' // bucketId
);
Update bucket
Update a storage bucket by its unique ID.
Request
bucketId requiredBucket unique ID.
name requiredBucket name
permissions An array of permission strings. By default, the current permissions are inherited. Learn more about permissions.
fileSecurity 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 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 Maximum file size allowed in bytes. Maximum allowed value is 30MB.
allowedFileExtensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.
compression Compression algorithm choosen for compression. Can be one of none, gzip, or zstd, For file size above 20MB compression is skipped even if it's enabled
encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled
antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled
Response
200
PUT /storage/buckets/{bucketId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new sdk.Storage(client);
const result = await storage.updateBucket(
'<BUCKET_ID>', // bucketId
'<NAME>', // name
["read("any")"], // permissions (optional)
false, // fileSecurity (optional)
false, // enabled (optional)
1, // maximumFileSize (optional)
[], // allowedFileExtensions (optional)
sdk..None, // compression (optional)
false, // encryption (optional)
false // antivirus (optional)
);
Delete bucket
Delete a storage bucket by its unique ID.
Request
bucketId requiredBucket unique ID.
Response
204
DELETE /storage/buckets/{bucketId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setKey('<YOUR_API_KEY>'); // Your secret API key
const storage = new sdk.Storage(client);
const result = await storage.deleteBucket(
'<BUCKET_ID>' // bucketId
);
List files
Get a list of all the user files. You can use the query params to filter your results.
Request
bucketId requiredStorage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
queries Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded
search Search term to filter your list results. Max length: 256 chars.
Response
200
GET /storage/buckets/{bucketId}/files
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new sdk.Storage(client);
const result = await storage.listFiles(
'<BUCKET_ID>', // bucketId
[], // queries (optional)
'<SEARCH>' // search (optional)
);
Create file
Create a new file. Before using this route, you should create a new bucket resource using either a server integration API or directly from your Appwrite console.
Larger files should be uploaded using multiple requests with the content-range header to send a partial request with a maximum supported chunk of 5MB
. The content-range
header values should always be in bytes.
When the first request is sent, the server will return the File object, and the subsequent part request must include the file's id in x-appwrite-id
header to allow the server to know that the partial upload is for the existing file and not for a new one.
If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally.
Request
bucketId requiredStorage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId requiredFile 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.file requiredBinary file. Appwrite SDKs provide helpers to handle file input. Learn about file input.
permissions An array of permission strings. By default, only the current user is granted all permissions. Learn more about permissions.
Response
201
Rate limits
This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with
setSession
, these rate limits will still apply. Learn more about SSR rate limits.The limit is applied for each unique limit key.
Time frameAttemptsKey1 minutes 60 requests IP + METHOD + URL + USER ID +
POST /storage/buckets/{bucketId}/files
const sdk = require('node-appwrite');
const fs = require('fs');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new sdk.Storage(client);
const result = await storage.createFile(
'<BUCKET_ID>', // bucketId
'<FILE_ID>', // fileId
InputFile.fromPath('/path/to/file', 'filename'), // file
["read("any")"] // permissions (optional)
);
Get file
Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.
Request
bucketId requiredStorage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId requiredFile ID.
Response
200
GET /storage/buckets/{bucketId}/files/{fileId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new sdk.Storage(client);
const result = await storage.getFile(
'<BUCKET_ID>', // bucketId
'<FILE_ID>' // fileId
);
Update file
Update a file by its unique ID. Only users with write permissions have access to update this resource.
Request
bucketId requiredStorage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId requiredFile unique ID.
name Name of the file
permissions An array of permission string. By default, the current permissions are inherited. Learn more about permissions.
Response
200
Rate limits
This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with
setSession
, these rate limits will still apply. Learn more about SSR rate limits.The limit is applied for each unique limit key.
Time frameAttemptsKey1 minutes 60 requests IP + METHOD + URL + USER ID
PUT /storage/buckets/{bucketId}/files/{fileId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new sdk.Storage(client);
const result = await storage.updateFile(
'<BUCKET_ID>', // bucketId
'<FILE_ID>', // fileId
'<NAME>', // name (optional)
["read("any")"] // permissions (optional)
);
Delete file
Delete a file by its unique ID. Only users with write permissions have access to delete this resource.
Request
bucketId requiredStorage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId requiredFile ID.
Response
204
Rate limits
This endpoint is not limited when using Server SDKs with API keys. If you are using SSR with
setSession
, these rate limits will still apply. Learn more about SSR rate limits.The limit is applied for each unique limit key.
Time frameAttemptsKey1 minutes 60 requests IP + METHOD + URL + USER ID
DELETE /storage/buckets/{bucketId}/files/{fileId}
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new sdk.Storage(client);
const result = await storage.deleteFile(
'<BUCKET_ID>', // bucketId
'<FILE_ID>' // fileId
);
Get file for download
Get a file content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.
Request
bucketId requiredStorage bucket ID. You can create a new storage bucket using the Storage service server integration.
fileId requiredFile ID.
Response
200
GET /storage/buckets/{bucketId}/files/{fileId}/download
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new sdk.Storage(client);
const result = await storage.getFileDownload(
'<BUCKET_ID>', // bucketId
'<FILE_ID>' // fileId
);
Get file preview
Get a file preview image. Currently, this method supports preview for image files (jpg, png, and gif), other supported formats, like pdf, docs, slides, and spreadsheets, will return the file icon image. You can also pass query string arguments for cutting and resizing your preview image. Preview is supported only for image files smaller than 10MB.
Request
bucketId requiredStorage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId requiredFile ID
width Resize preview image width, Pass an integer between 0 to 4000.
height Resize preview image height, Pass an integer between 0 to 4000.
gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
quality Preview image quality. Pass an integer between 0 to 100. Defaults to 100.
borderWidth Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.
borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix.
borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000.
opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
rotation Preview image rotation in degrees. Pass an integer between -360 and 360.
background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
output Output format type (jpeg, jpg, png, gif and webp).
Response
200
GET /storage/buckets/{bucketId}/files/{fileId}/preview
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new sdk.Storage(client);
const result = await storage.getFilePreview(
'<BUCKET_ID>', // bucketId
'<FILE_ID>', // fileId
0, // width (optional)
0, // height (optional)
sdk.ImageGravity.Center, // gravity (optional)
0, // quality (optional)
0, // borderWidth (optional)
'', // borderColor (optional)
0, // borderRadius (optional)
0, // opacity (optional)
-360, // rotation (optional)
'', // background (optional)
sdk.ImageFormat.Jpg // output (optional)
);
Get file for view
Get a file content by its unique ID. This endpoint is similar to the download method but returns with no 'Content-Disposition: attachment' header.
Request
bucketId requiredStorage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
fileId requiredFile ID.
Response
200
GET /storage/buckets/{bucketId}/files/{fileId}/view
const sdk = require('node-appwrite');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with
const storage = new sdk.Storage(client);
const result = await storage.getFileView(
'<BUCKET_ID>', // bucketId
'<FILE_ID>' // fileId
);