View Source Appwrite.Services.Storage (appwrite v0.1.6)
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
Functions
Create a new file in a bucket.
Delete a file by its unique ID.
Get a file by its unique ID.
Get a file for download.
Get a file preview.
Get a file for viewing.
List files in a bucket.
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
@spec create_file( bucket_id(), file_id(), Appwrite.Types.File.t(), permissions() | nil ) :: {:ok, Appwrite.Types.File.t()} | {:error, Appwrite.Exceptions.AppwriteException.t()}
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.
@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.
@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.
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.
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.
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.
@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.