Appwrite. Services. Storage
(appwrite v1.0.0)
View Source
The Storage service allows you to manage your project files.
File format for uploads
The file_info argument accepted by create_file/5 must be a map with the
following string keys:
%{
"name" => "report.pdf", # display filename
"data" => <<binary content>>, # raw binary — NOT base64 at call site
"type" => "application/pdf", # MIME type
"size" => 204_800 # byte length (integer)
}The SDK handles base64 encoding internally for chunked uploads.
See CHANGELOG.md for version history.
Summary
Functions
Create (upload) a new file. Files larger than 5 MB are uploaded in chunks
automatically using Client.chunked_upload/5.
Delete a file by its unique ID.
Get file metadata by its unique ID.
Build a file download URL.
Build a file preview URL.
Build a file view URL (inline browser display).
List files in a storage bucket.
Update a file's display name and/or permissions.
Functions
@spec create_file( String.t(), String.t(), %{required(String.t()) => String.t() | binary() | integer()}, [String.t()] | nil, (map() -> any()) | nil ) :: {:ok, map()} | {:error, any()}
Create (upload) a new file. Files larger than 5 MB are uploaded in chunks
automatically using Client.chunked_upload/5.
Parameters
bucket_id(required)file_id(required) — useAppwrite.Utils.Id.unique()to auto-generatefile_info(required) — map with string keys:"name"— display filename (e.g."report.pdf")"data"— raw binary content"type"— MIME type (e.g."application/pdf")"size"— byte length as integer
permissions(optional) — list of permission stringson_progress(optional) — 1-arity callback called after each chunk with%Appwrite.Types.Client.UploadProgress{}
Delete a file by its unique ID.
Get file metadata by its unique ID.
@spec get_file_download(String.t(), String.t(), String.t() | nil) :: {:ok, String.t()} | {:error, any()}
Build a file download URL.
Parameters
bucket_id(required)file_id(required)token(optional) — file token for unauthenticated access via the Tokens API
Build a file preview URL.
Parameters
bucket_id(required)file_id(required)opts— optional keyword list::width,:height,:gravity,:quality:border_width,:border_color,:border_radius:opacity,:rotation,:background,:output:token— file token for unauthenticated access
@spec get_file_view(String.t(), String.t(), String.t() | nil) :: {:ok, String.t()} | {:error, any()}
Build a file view URL (inline browser display).
Parameters
bucket_id(required)file_id(required)token(optional) — file token for unauthenticated access
@spec list_files(String.t(), [String.t()] | nil, String.t() | nil, boolean() | nil) :: {:ok, map()} | {:error, any()}
List files in a storage bucket.
Parameters
bucket_id(required)queries(optional) — list of query stringssearch(optional) — text search termtotal(optional) — whenfalse, skips count calculation for performance
@spec update_file(String.t(), String.t(), String.t() | nil, [String.t()] | nil) :: {:ok, map()} | {:error, any()}
Update a file's display name and/or permissions.
Parameters
bucket_id(required)file_id(required)name(optional) — new display namepermissions(optional) — replacement permission list