View Source Appwrite.Services.Storage (appwrite v0.1.7)

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.

Each file in the service is granted with read and write permissions to manage who has access to view or edit it. You can also learn more about how to manage your resources permissions.

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.

Summary

Types

@type bucket_id() :: String.t()
@type file_id() :: String.t()
@type payload() :: Appwrite.Types.Client.Payload.t()
@type permissions() :: [String.t()]
@type queries() :: [String.t()]

Functions

Link to this function

create_file(bucket_id, file_id, file, permissions \\ nil)

View Source

Create a new file in a bucket.

Parameters

  • bucket_id (String): The ID of the bucket.
  • file_id (String): Unique ID for the file.
  • file (File): The file to upload.
  • permissions (list of String, optional): Permissions for the file.

Returns

  • {:ok, File.t()} on success.
  • {:error, AppwriteException.t()} on failure.
Link to this function

delete_file(bucket_id, file_id)

View Source
@spec delete_file(bucket_id(), file_id()) ::
  {:ok, :deleted} | {:error, Appwrite.Exceptions.AppwriteException.t()}

Delete a file by its unique ID.

Parameters

  • bucket_id (String): The ID of the bucket.
  • file_id (String): The ID of the file.

Returns

  • {:ok, :deleted} on success.
  • {:error, AppwriteException.t()} on failure.
Link to this function

get_file(bucket_id, file_id)

View Source
@spec get_file(bucket_id(), file_id()) ::
  {:ok, Appwrite.Types.File.t()}
  | {:error, Appwrite.Exceptions.AppwriteException.t()}

Get a file by its unique ID.

Parameters

  • bucket_id (String): The ID of the bucket.
  • file_id (String): The ID of the file.

Returns

  • {:ok, File.t()} on success.
  • {:error, AppwriteException.t()} on failure.
Link to this function

get_file_download(bucket_id, file_id)

View Source
@spec get_file_download(String.t(), String.t()) :: String.t()

Get a file for download.

Retrieves the file content by its unique ID. The response includes a Content-Disposition: attachment header, prompting the browser to download the file.

Parameters

  • bucket_id (String.t): The ID of the bucket.
  • file_id (String.t): The ID of the file.

Returns

  • String.t: The URI for downloading the file.

Raises

  • AppwriteException if parameters are missing or request fails.
Link to this function

get_file_preview(bucket_id, file_id, options \\ [])

View Source
@spec get_file_preview(
  String.t(),
  String.t(),
  keyword()
) :: String.t()

Get a file preview.

Generates a preview of an image file. Supports query string arguments for resizing and customization.

Parameters

  • bucket_id (String.t): The ID of the bucket.
  • file_id (String.t): The ID of the file.
  • Optional preview settings (width, height, gravity, quality, etc.).

Returns

  • String.t: The URI for the file preview.

Raises

  • AppwriteException if parameters are missing or invalid.
Link to this function

get_file_view(bucket_id, file_id)

View Source
@spec get_file_view(String.t(), String.t()) :: String.t()

Get a file for viewing.

Retrieves file content by its unique ID. Unlike download, it does not include the Content-Disposition: attachment header.

Parameters

  • bucket_id (String.t): The ID of the bucket.
  • file_id (String.t): The ID of the file.

Returns

  • String.t: The URI for viewing the file.

Raises

  • AppwriteException if parameters are missing.
Link to this function

list_files(bucket_id, queries \\ nil, search \\ nil)

View Source
@spec list_files(bucket_id(), queries() | nil, String.t() | nil) ::
  {:ok, Appwrite.Types.FileList.t()}
  | {:error, Appwrite.Exceptions.AppwriteException.t()}

List files in a bucket.

Parameters

  • bucket_id (String): The ID of the bucket.
  • queries (list of String, optional): Queries to filter the results.
  • search (String, optional): Search query to filter files.

Returns

  • {:ok, FileList.t()} on success.
  • {:error, AppwriteException.t()} on failure.