Start with Storage

You can create your first bucket, upload, and download your first file in minutes.

Create bucket

You can create a bucket in the Appwrite Console by navigating to Storage > Create bucket.

In your bucket, navigate to Settings > Permissions, then add a new Any role with CREATE and READ permissions. This allows anyone to create and read files in this bucket.

Create file

To upload a file, add this to your web, Flutter, Apple, or Android app.

import { Client, Storage } from "appwrite";

const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>');

const storage = new Storage(client);

const promise = storage.createFile(
    '[BUCKET_ID]',
    ID.unique(),
    document.getElementById('uploader').files[0]
);

promise.then(function (response) {
    console.log(response); // Success
}, function (error) {
    console.log(error); // Failure
});

Download file

To download a file, use the getFileDownload method.

import { Client, Storage } from "appwrite";

const client = new Client();

const storage = new Storage(client);

client
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('<PROJECT_ID>') // Your project ID
;

const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]');

console.log(result); // Resource URL