Appwrite is now available as a DigitalOcean 1-click app! Click to install! 🚀
Docs

Storage API


Client integration with  

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.

The maximum file size allowed for file upload is controlled by the _APP_STORAGE_LIMIT environment variable, which defaults to 30 MB. See Environment Variables for more information.

Create File

POST/v1/storage/buckets/{bucketId}/files

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.

Rate Limits

This endpoint is limited to 60 requests in every 1 minutes per IP address, method and user account. We use rate limits to avoid service abuse by users and as a security practice. Learn more about rate limiting.

HTTP Request

Name Type Description
bucketId required string

Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.

fileId required string

File ID. Choose your own unique ID or pass the string "unique()" to auto generate it. 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 required file

Binary file.

permissions optional array

An array of permission strings. By default the current user is granted with all permissions. Learn more about permissions.

HTTP Response

Status Code Content Type Payload
201  Created application/json File Object
Example Request
  • import { Client, Storage } from "appwrite";
    
    const client = new Client();
    
    const storage = new Storage(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = storage.createFile('[BUCKET_ID]', '[FILE_ID]', document.getElementById('uploader').files[0]);
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'dart:io';
    import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Storage storage = Storage(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = storage.createFile(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
        file: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'),
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    func main() async throws {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
        let storage = Storage(client)
        let file = try await storage.createFile(
            bucketId: "[BUCKET_ID]",
            fileId: "[FILE_ID]",
            file: InputFile.fromPath("file.png")
        )
    
        print(String(describing: file)
    }
    
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.models.InputFile
    import io.appwrite.services.Storage
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val client = Client(applicationContext)
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2") // Your project ID
    
            val storage = Storage(client)
    
            GlobalScope.launch {
                val response = storage.createFile(
                    bucketId = "[BUCKET_ID]",
                    fileId = "[FILE_ID]",
                    file = InputFile.fromPath("file.png"),
                )
                val json = response.body?.string()        
            }
        }
    }
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.models.InputFile
    import io.appwrite.services.Storage
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Client client = new Client(getApplicationContext())
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2"); // Your project ID
    
            Storage storage = new Storage(client);
    
            storage.createFile(
                "[BUCKET_ID]", 
                "[FILE_ID]", 
                InputFile.fromPath("file.png"), 
                new Continuation<Object>() {
                    @NotNull
                    @Override
                    public CoroutineContext getContext() {
                        return EmptyCoroutineContext.INSTANCE;
                    }
    
                    @Override
                    public void resumeWith(@NotNull Object o) {
                        String json = "";
                        try {
                            if (o instanceof Result.Failure) {
                                Result.Failure failure = (Result.Failure) o;
                                throw failure.exception;
                            } else {
                                Response response = (Response) o;
                                json = response.body().string();
                            }                    
                        } catch (Throwable th) {
                            Log.e("ERROR", th.toString());
                        }
                    }
                }
            );
        }
    }

List Files

GET/v1/storage/buckets/{bucketId}/files

Get a list of all the user files. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's files. Learn more about different API modes.

HTTP Request

Name Type Description
bucketId required string

Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.

queries optional array

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 optional string

Search term to filter your list results. Max length: 256 chars.

HTTP Response

Status Code Content Type Payload
200  OK application/json Files List Object
Example Request
  • import { Client, Storage } from "appwrite";
    
    const client = new Client();
    
    const storage = new Storage(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = storage.listFiles('[BUCKET_ID]');
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Storage storage = Storage(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = storage.listFiles(
        bucketId: '[BUCKET_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    func main() async throws {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
        let storage = Storage(client)
        let fileList = try await storage.listFiles(
            bucketId: "[BUCKET_ID]"
        )
    
        print(String(describing: fileList)
    }
    
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val client = Client(applicationContext)
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2") // Your project ID
    
            val storage = Storage(client)
    
            GlobalScope.launch {
                val response = storage.listFiles(
                    bucketId = "[BUCKET_ID]",
                )
                val json = response.body?.string()        
            }
        }
    }
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Client client = new Client(getApplicationContext())
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2"); // Your project ID
    
            Storage storage = new Storage(client);
    
            storage.listFiles(
                "[BUCKET_ID]", 
                new Continuation<Object>() {
                    @NotNull
                    @Override
                    public CoroutineContext getContext() {
                        return EmptyCoroutineContext.INSTANCE;
                    }
    
                    @Override
                    public void resumeWith(@NotNull Object o) {
                        String json = "";
                        try {
                            if (o instanceof Result.Failure) {
                                Result.Failure failure = (Result.Failure) o;
                                throw failure.exception;
                            } else {
                                Response response = (Response) o;
                                json = response.body().string();
                            }                    
                        } catch (Throwable th) {
                            Log.e("ERROR", th.toString());
                        }
                    }
                }
            );
        }
    }

Get File

GET/v1/storage/buckets/{bucketId}/files/{fileId}

Get a file by its unique ID. This endpoint response returns a JSON object with the file metadata.

HTTP Request

Name Type Description
bucketId required string

Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.

fileId required string

File ID.

HTTP Response

Status Code Content Type Payload
200  OK application/json File Object
Example Request
  • import { Client, Storage } from "appwrite";
    
    const client = new Client();
    
    const storage = new Storage(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = storage.getFile('[BUCKET_ID]', '[FILE_ID]');
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Storage storage = Storage(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = storage.getFile(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    func main() async throws {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
        let storage = Storage(client)
        let file = try await storage.getFile(
            bucketId: "[BUCKET_ID]",
            fileId: "[FILE_ID]"
        )
    
        print(String(describing: file)
    }
    
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val client = Client(applicationContext)
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2") // Your project ID
    
            val storage = Storage(client)
    
            GlobalScope.launch {
                val response = storage.getFile(
                    bucketId = "[BUCKET_ID]",
                    fileId = "[FILE_ID]"
                )
                val json = response.body?.string()        
            }
        }
    }
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Client client = new Client(getApplicationContext())
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2"); // Your project ID
    
            Storage storage = new Storage(client);
    
            storage.getFile(
                "[BUCKET_ID]", 
                "[FILE_ID]"
                new Continuation<Object>() {
                    @NotNull
                    @Override
                    public CoroutineContext getContext() {
                        return EmptyCoroutineContext.INSTANCE;
                    }
    
                    @Override
                    public void resumeWith(@NotNull Object o) {
                        String json = "";
                        try {
                            if (o instanceof Result.Failure) {
                                Result.Failure failure = (Result.Failure) o;
                                throw failure.exception;
                            } else {
                                Response response = (Response) o;
                                json = response.body().string();
                            }                    
                        } catch (Throwable th) {
                            Log.e("ERROR", th.toString());
                        }
                    }
                }
            );
        }
    }

Get File Preview

GET/v1/storage/buckets/{bucketId}/files/{fileId}/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.

HTTP Request

Name Type Description
bucketId required string

Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.

fileId required string

File ID

width optional integer

Resize preview image width, Pass an integer between 0 to 4000.

height optional integer

Resize preview image height, Pass an integer between 0 to 4000.

gravity optional string

Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right

quality optional integer

Preview image quality. Pass an integer between 0 to 100. Defaults to 100.

borderWidth optional integer

Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0.

borderColor optional string

Preview image border color. Use a valid HEX color, no # is needed for prefix.

borderRadius optional integer

Preview image border radius in pixels. Pass an integer between 0 to 4000.

opacity optional number

Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.

rotation optional integer

Preview image rotation in degrees. Pass an integer between -360 and 360.

background optional string

Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.

output optional string

Output format type (jpeg, jpg, png, gif and webp).

HTTP Response

Status Code Content Type Payload
200  OK image/* -
Example Request
  • import { Client, Storage } from "appwrite";
    
    const client = new Client();
    
    const storage = new Storage(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const result = storage.getFilePreview('[BUCKET_ID]', '[FILE_ID]');
    
    console.log(result); // Resource URL
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Storage storage = Storage(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      // downloading file
      Future result = storage.getFilePreview(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
      ).then((bytes) {
        final file = File('path_to_file/filename.ext');
        file.writeAsBytesSync(bytes)
      }).catchError((error) {
          print(error.response);
      })
    }
    
    //displaying image preview
    FutureBuilder(
      future: storage.getFilePreview(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
      ), //works for both public file and private file, for private files you need to be logged in
      builder: (context, snapshot) {
        return snapshot.hasData && snapshot.data != null
          ? Image.memory(
              snapshot.data,
            )
          : CircularProgressIndicator();
      },
    );
    
  • import Appwrite
    
    func main() async throws {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
        let storage = Storage(client)
        let byteBuffer = try await storage.getFilePreview(
            bucketId: "[BUCKET_ID]",
            fileId: "[FILE_ID]"
        )
    
        print(String(describing: byteBuffer)
    }
    
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val client = Client(applicationContext)
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2") // Your project ID
    
            val storage = Storage(client)
    
            GlobalScope.launch {
                val result = storage.getFilePreview(
                    bucketId = "[BUCKET_ID]",
                    fileId = "[FILE_ID]",
                )
                println(result); // Resource URL        
            }
        }
    }
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Client client = new Client(getApplicationContext())
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2"); // Your project ID
    
            Storage storage = new Storage(client);
    
            storage.getFilePreview(
                "[BUCKET_ID]", 
                "[FILE_ID]", 
                new Continuation<Object>() {
                    @NotNull
                    @Override
                    public CoroutineContext getContext() {
                        return EmptyCoroutineContext.INSTANCE;
                    }
    
                    @Override
                    public void resumeWith(@NotNull Object o) {
                        String json = "";
                        try {
                            if (o instanceof Result.Failure) {
                                Result.Failure failure = (Result.Failure) o;
                                throw failure.exception;
                            } else {
                                Response response = (Response) o;
                                json = response.body().string();
                            }                    
                        } catch (Throwable th) {
                            Log.e("ERROR", th.toString());
                        }
                    }
                }
            );
        }
    }

Get File for Download

GET/v1/storage/buckets/{bucketId}/files/{fileId}/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.

HTTP Request

Name Type Description
bucketId required string

Storage bucket ID. You can create a new storage bucket using the Storage service server integration.

fileId required string

File ID.

HTTP Response

Status Code Content Type Payload
200  OK */* -
Example Request
  • import { Client, Storage } from "appwrite";
    
    const client = new Client();
    
    const storage = new Storage(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const result = storage.getFileDownload('[BUCKET_ID]', '[FILE_ID]');
    
    console.log(result); // Resource URL
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Storage storage = Storage(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      // downloading file
      Future result = storage.getFileDownload(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
      ).then((bytes) {
        final file = File('path_to_file/filename.ext');
        file.writeAsBytesSync(bytes)
      }).catchError((error) {
          print(error.response);
      })
    }
    
    //displaying image preview
    FutureBuilder(
      future: storage.getFileDownload(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
      ), //works for both public file and private file, for private files you need to be logged in
      builder: (context, snapshot) {
        return snapshot.hasData && snapshot.data != null
          ? Image.memory(
              snapshot.data,
            )
          : CircularProgressIndicator();
      },
    );
    
  • import Appwrite
    
    func main() async throws {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
        let storage = Storage(client)
        let byteBuffer = try await storage.getFileDownload(
            bucketId: "[BUCKET_ID]",
            fileId: "[FILE_ID]"
        )
    
        print(String(describing: byteBuffer)
    }
    
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val client = Client(applicationContext)
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2") // Your project ID
    
            val storage = Storage(client)
    
            GlobalScope.launch {
                val result = storage.getFileDownload(
                    bucketId = "[BUCKET_ID]",
                    fileId = "[FILE_ID]"
                )
                println(result); // Resource URL        
            }
        }
    }
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Client client = new Client(getApplicationContext())
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2"); // Your project ID
    
            Storage storage = new Storage(client);
    
            storage.getFileDownload(
                "[BUCKET_ID]", 
                "[FILE_ID]"
                new Continuation<Object>() {
                    @NotNull
                    @Override
                    public CoroutineContext getContext() {
                        return EmptyCoroutineContext.INSTANCE;
                    }
    
                    @Override
                    public void resumeWith(@NotNull Object o) {
                        String json = "";
                        try {
                            if (o instanceof Result.Failure) {
                                Result.Failure failure = (Result.Failure) o;
                                throw failure.exception;
                            } else {
                                Response response = (Response) o;
                                json = response.body().string();
                            }                    
                        } catch (Throwable th) {
                            Log.e("ERROR", th.toString());
                        }
                    }
                }
            );
        }
    }

Get File for View

GET/v1/storage/buckets/{bucketId}/files/{fileId}/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.

HTTP Request

Name Type Description
bucketId required string

Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.

fileId required string

File ID.

HTTP Response

Status Code Content Type Payload
200  OK */* -
Example Request
  • import { Client, Storage } from "appwrite";
    
    const client = new Client();
    
    const storage = new Storage(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const result = storage.getFileView('[BUCKET_ID]', '[FILE_ID]');
    
    console.log(result); // Resource URL
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Storage storage = Storage(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      // downloading file
      Future result = storage.getFileView(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
      ).then((bytes) {
        final file = File('path_to_file/filename.ext');
        file.writeAsBytesSync(bytes)
      }).catchError((error) {
          print(error.response);
      })
    }
    
    //displaying image preview
    FutureBuilder(
      future: storage.getFileView(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
      ), //works for both public file and private file, for private files you need to be logged in
      builder: (context, snapshot) {
        return snapshot.hasData && snapshot.data != null
          ? Image.memory(
              snapshot.data,
            )
          : CircularProgressIndicator();
      },
    );
    
  • import Appwrite
    
    func main() async throws {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
        let storage = Storage(client)
        let byteBuffer = try await storage.getFileView(
            bucketId: "[BUCKET_ID]",
            fileId: "[FILE_ID]"
        )
    
        print(String(describing: byteBuffer)
    }
    
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val client = Client(applicationContext)
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2") // Your project ID
    
            val storage = Storage(client)
    
            GlobalScope.launch {
                val result = storage.getFileView(
                    bucketId = "[BUCKET_ID]",
                    fileId = "[FILE_ID]"
                )
                println(result); // Resource URL        
            }
        }
    }
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Client client = new Client(getApplicationContext())
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2"); // Your project ID
    
            Storage storage = new Storage(client);
    
            storage.getFileView(
                "[BUCKET_ID]", 
                "[FILE_ID]"
                new Continuation<Object>() {
                    @NotNull
                    @Override
                    public CoroutineContext getContext() {
                        return EmptyCoroutineContext.INSTANCE;
                    }
    
                    @Override
                    public void resumeWith(@NotNull Object o) {
                        String json = "";
                        try {
                            if (o instanceof Result.Failure) {
                                Result.Failure failure = (Result.Failure) o;
                                throw failure.exception;
                            } else {
                                Response response = (Response) o;
                                json = response.body().string();
                            }                    
                        } catch (Throwable th) {
                            Log.e("ERROR", th.toString());
                        }
                    }
                }
            );
        }
    }

Update File

PUT/v1/storage/buckets/{bucketId}/files/{fileId}

Update a file by its unique ID. Only users with write permissions have access to update this resource.

Rate Limits

This endpoint is limited to 60 requests in every 1 minutes per IP address, method and user account. We use rate limits to avoid service abuse by users and as a security practice. Learn more about rate limiting.

HTTP Request

Name Type Description
bucketId required string

Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.

fileId required string

File unique ID.

permissions optional array

An array of permission string. By default the current permissions are inherited. Learn more about permissions.

HTTP Response

Status Code Content Type Payload
200  OK application/json File Object
Example Request
  • import { Client, Storage } from "appwrite";
    
    const client = new Client();
    
    const storage = new Storage(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = storage.updateFile('[BUCKET_ID]', '[FILE_ID]');
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Storage storage = Storage(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = storage.updateFile(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    func main() async throws {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
        let storage = Storage(client)
        let file = try await storage.updateFile(
            bucketId: "[BUCKET_ID]",
            fileId: "[FILE_ID]"
        )
    
        print(String(describing: file)
    }
    
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val client = Client(applicationContext)
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2") // Your project ID
    
            val storage = Storage(client)
    
            GlobalScope.launch {
                val response = storage.updateFile(
                    bucketId = "[BUCKET_ID]",
                    fileId = "[FILE_ID]",
                )
                val json = response.body?.string()        
            }
        }
    }
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Client client = new Client(getApplicationContext())
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2"); // Your project ID
    
            Storage storage = new Storage(client);
    
            storage.updateFile(
                "[BUCKET_ID]", 
                "[FILE_ID]", 
                new Continuation<Object>() {
                    @NotNull
                    @Override
                    public CoroutineContext getContext() {
                        return EmptyCoroutineContext.INSTANCE;
                    }
    
                    @Override
                    public void resumeWith(@NotNull Object o) {
                        String json = "";
                        try {
                            if (o instanceof Result.Failure) {
                                Result.Failure failure = (Result.Failure) o;
                                throw failure.exception;
                            } else {
                                Response response = (Response) o;
                                json = response.body().string();
                            }                    
                        } catch (Throwable th) {
                            Log.e("ERROR", th.toString());
                        }
                    }
                }
            );
        }
    }

Delete File

DELETE/v1/storage/buckets/{bucketId}/files/{fileId}

Delete a file by its unique ID. Only users with write permissions have access to delete this resource.

Rate Limits

This endpoint is limited to 60 requests in every 1 minutes per IP address, method and user account. We use rate limits to avoid service abuse by users and as a security practice. Learn more about rate limiting.

HTTP Request

Name Type Description
bucketId required string

Storage bucket unique ID. You can create a new storage bucket using the Storage service server integration.

fileId required string

File ID.

HTTP Response

Status Code Content Type Payload
204  No Content - -
Example Request
  • import { Client, Storage } from "appwrite";
    
    const client = new Client();
    
    const storage = new Storage(client);
    
    client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
    ;
    
    const promise = storage.deleteFile('[BUCKET_ID]', '[FILE_ID]');
    
    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
  • import 'package:appwrite/appwrite.dart';
    
    void main() { // Init SDK
      Client client = Client();
      Storage storage = Storage(client);
    
      client
        .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
        .setProject('5df5acd0d48c2') // Your project ID
      ;
      Future result = storage.deleteFile(
        bucketId: '[BUCKET_ID]',
        fileId: '[FILE_ID]',
      );
    
      result
        .then((response) {
          print(response);
        }).catchError((error) {
          print(error.response);
      });
    }
    
  • import Appwrite
    
    func main() async throws {
        let client = Client()
          .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
          .setProject("5df5acd0d48c2") // Your project ID
        let storage = Storage(client)
        let result = try await storage.deleteFile(
            bucketId: "[BUCKET_ID]",
            fileId: "[FILE_ID]"
        )
    
        print(String(describing: result)
    }
    
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            val client = Client(applicationContext)
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2") // Your project ID
    
            val storage = Storage(client)
    
            GlobalScope.launch {
                val response = storage.deleteFile(
                    bucketId = "[BUCKET_ID]",
                    fileId = "[FILE_ID]"
                )
                val json = response.body?.string()        
            }
        }
    }
  • import androidx.appcompat.app.AppCompatActivity
    import android.os.Bundle
    import kotlinx.coroutines.GlobalScope
    import kotlinx.coroutines.launch
    import io.appwrite.Client
    import io.appwrite.services.Storage
    
    public class MainActivity extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Client client = new Client(getApplicationContext())
                .setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
                .setProject("5df5acd0d48c2"); // Your project ID
    
            Storage storage = new Storage(client);
    
            storage.deleteFile(
                "[BUCKET_ID]", 
                "[FILE_ID]"
                new Continuation<Object>() {
                    @NotNull
                    @Override
                    public CoroutineContext getContext() {
                        return EmptyCoroutineContext.INSTANCE;
                    }
    
                    @Override
                    public void resumeWith(@NotNull Object o) {
                        String json = "";
                        try {
                            if (o instanceof Result.Failure) {
                                Result.Failure failure = (Result.Failure) o;
                                throw failure.exception;
                            } else {
                                Response response = (Response) o;
                                json = response.body().string();
                            }                    
                        } catch (Throwable th) {
                            Log.e("ERROR", th.toString());
                        }
                    }
                }
            );
        }
    }