Create file
Endpoint
posthttps://<REGION>.cloud.appwrite.io/v1/storage/buckets/{bucketId}/files
Description
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.
Required scopes
Authentication
setProject() and ensure the user is signed in. The SDK sends the session header automatically after login.Rate limit
Path
Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
Body
File 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.
Binary file. Appwrite SDKs provide helpers to handle file input. Learn about file input.
An array of permission strings. By default, only the current user is granted all permissions. Learn more about permissions.
File
File ID.
Bucket ID.
File creation date in ISO 8601 format.
File update date in ISO 8601 format.
File permissions. Learn more about permissions.
File name.
File MD5 signature.
File mime type.
File original size in bytes.
File actual stored size in bytes after compression and/or encryption.
Total number of chunks available
Total number of chunks uploaded
Whether file contents are encrypted at rest.
import { Client, Storage, Permission, Role } from "appwrite";
const client = new Client() .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = await storage.createFile({ bucketId: '<BUCKET_ID>', fileId: '<FILE_ID>', file: document.getElementById('uploader').files[0], permissions: [Permission.read(Role.any())] // optional});
console.log(result);Storage
files
Create file
Endpoint
posthttps://<REGION>.cloud.appwrite.io/v1/storage/buckets/{bucketId}/files
Description
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.
Required scopes
Authentication
setProject() and ensure the user is signed in. The SDK sends the session header automatically after login.Rate limit
Path
Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.
Body
File 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.
Binary file. Appwrite SDKs provide helpers to handle file input. Learn about file input.
An array of permission strings. By default, only the current user is granted all permissions. Learn more about permissions.
File
File ID.
Bucket ID.
File creation date in ISO 8601 format.
File update date in ISO 8601 format.
File permissions. Learn more about permissions.
File name.
File MD5 signature.
File mime type.
File original size in bytes.
File actual stored size in bytes after compression and/or encryption.
Total number of chunks available
Total number of chunks uploaded
Whether file contents are encrypted at rest.
import { Client, Storage, Permission, Role } from "appwrite";
const client = new Client() .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID
const storage = new Storage(client);
const result = await storage.createFile({ bucketId: '<BUCKET_ID>', fileId: '<FILE_ID>', file: document.getElementById('uploader').files[0], permissions: [Permission.read(Role.any())] // optional});
console.log(result);