Introducing a new way to review your PRs.

Read the announcement

appwrite / sdk-for-react-native

[READ ONLY] Official Appwrite React Native SDK 💙 ⚛︎

View on GitHub

24 documents · Updated Nov 18, 2026

docs / storage-file-lifecycle

Storage file lifecycle

The Storage service manages the life of user files inside a bucket. It covers file creation, file metadata, access rules, content delivery, previews, updates, and removal. This page gives the broad model for the service; see Data, files, and execution services for its place in the wider platform, Databases and TablesDB records for structured data, VectorsDB documents and queries for vector data, and Functions and GraphQL for other service access patterns.

Storage model

Buckets and file identity

The Storage service groups files in buckets, which provide the scope for file operations. Each file has a bucket ID and a file ID, while its metadata describes the file without returning its content. The bucket scopes lists, while the bucket and file ID pair identifies one file for retrieval, update, deletion, and content delivery.

References: src/…/storage.ts• L25-30 src/…/storage.ts• L511-572

Permissions and access

Permissions control who can read or change a file. A new file can receive explicit permissions, while an update can change its name and permissions; write access is required for updates and deletion. A file token is an alternate access value for content, preview, and view requests when the caller uses token-based access.

References: src/…/storage.ts• L137-151 src/…/storage.ts• L574-589 src/…/storage.ts• L686-704 src/…/storage.ts• L757-770 src/…/storage.ts• L854-889 src/…/storage.ts• L1117-1130

File lifecycle

Upload flow

The upload flow turns a local file into a Storage file and returns file metadata when the service accepts it. The SDK sends small files in one request and sends larger files in bounded chunks, so the caller can track progress while the service assembles one logical file.

This diagram shows how a local file moves through bucket creation, upload, and later file use.

flowchart LR
    A[Existing bucket] --> B[Local file]
    B --> C{File size}
    C -->|Small| D[Single upload]
    C -->|Large| E[Chunked upload]
    E --> F[Assembled Storage file]
    D --> F
    F --> G[Metadata and content operations]

Large uploads can resume from the service's recorded chunk state. The SDK uses the supplied file ID to find an existing upload, then uses the returned upload ID to associate later chunks with that file. After the first chunk establishes the upload, the remaining chunks can be sent with bounded parallelism. It reports uploaded bytes and chunk progress when a progress callback is supplied.

References: src/…/storage.ts• L127-151 src/…/storage.ts• L172-203 src/…/storage.ts• L288-336 src/…/storage.ts• L355-565 docs/…/create-file.md• L8-17

Metadata retrieval and listing

Metadata retrieval and listing support two levels of file discovery. A single-file request returns the metadata for one known file, while a list request returns files in one bucket and can narrow the result with queries or a search term. The list can also omit total-count calculation when the caller does not need it.

These operations describe and find files. They do not deliver the file bytes, which keeps metadata workflows separate from download, view, and preview workflows.

References: src/…/storage.ts• L15-30 src/…/storage.ts• L97-124 src/…/storage.ts• L503-572 docs/…/list-files.md• L8-17 docs/…/get-file.md• L8-15

Metadata updates and deletion

An update changes the file's name or permissions without replacing its content. Deletion removes the file from its bucket and ends the normal lifecycle for that file ID, so clients must not treat an old metadata record or content URL as a live resource after deletion.

References: src/…/storage.ts• L574-684 src/…/storage.ts• L686-755 docs/…/update-file.md• L8-17 docs/…/delete-file.md• L8-15

Content delivery

Download and view

Download and view return the original file content for a known bucket and file. Download marks the response as an attachment so a browser can save it, while view returns content without that attachment behavior so a client can display it when the format supports display.

Both content paths can use a file token and return binary data rather than file metadata. The SDK also exposes URL forms for download and view when a client needs a resource URL instead of an immediate content response.

References: src/…/storage.ts• L757-852 src/…/storage.ts• L1117-1212 src/…/storage.ts• L1214-1245 src/…/storage.ts• L1348-1393 src/…/storage.ts• L1517-1562 docs/…/get-file-download.md• L8-16 docs/…/get-file-view.md• L8-16

Preview generation

Preview generation produces an image-oriented representation for display. Image files can be resized or transformed, and the caller can choose an output image format; supported document types can instead produce a file icon. Preview support is limited for image files larger than 10 MB, so preview is a presentation path rather than a replacement for the original file.

Preview options describe the requested presentation, such as size, crop position, quality, borders, opacity, rotation, background, and output format. The same options are available when the caller requests preview bytes or builds a preview URL.

References: src/…/storage.ts• L877-998 src/…/storage.ts• L999-1245 src/…/storage.ts• L1395-1515 docs/…/get-file-preview.md• L8-27

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the upload size boundary, chunk association rules, bounded upload behavior, and progress values aligned between the upload path and any caller-facing examples.
  • Keep permission behavior consistent across creation, metadata updates, deletion, metadata reads, and binary content requests.
  • Keep preview option names and accepted values aligned between preview bytes and preview URL requests, including the ImageGravity and ImageFormat types.
  • Preserve the distinction between metadata responses and binary responses when changing endpoint behavior or client response handling.
  • Keep URL-building helpers aligned with their matching download, view, and preview content paths.
  • Update the related lifecycle page when bucket or file identity rules change, because those rules connect Storage to the wider data-service model.

Important failure modes

TriggerConsequenceGuard
The bucket ID or file ID is missingThe request cannot identify its Storage scope or file and fails before the service operationTreat both IDs as required for every file operation and preserve them across lifecycle calls
A large upload loses its chunk associationLater chunks can start a different upload or leave the intended file incompleteKeep the file ID and the service upload identifier with the resumed upload
The caller lacks the needed permission or supplies an unusable tokenMetadata or content access fails, or a write operation is rejectedSet permissions at creation or update and use a valid token only for the intended file
A preview request targets an unsupported or oversized imageThe requested image preview cannot be produced; some supported non-image formats return an icon insteadUse preview for supported, small images and use view or download for the original content
A client uses a deleted file ID or old content URLThe resource is no longer available through the normal file lifecycleRemove stale references after deletion and resolve a current file before content access

Key files

FileWhy to read it
src/…/storage.tsDefines the Storage service contract for listing, uploading, reading, updating, deleting, downloading, viewing, previewing, and building content URLs for files.
docs/…/create-file.mdShows the user-facing upload shape and the relationship between a bucket, file ID, local file, and permissions.
docs/…/list-files.mdShows how a bucket-scoped file list can use search, queries, and total-count behavior.
docs/…/get-file.mdShows the metadata lookup flow for a known file.
docs/…/update-file.mdShows the metadata and permission update flow.
docs/…/delete-file.mdShows the terminal deletion operation for a file.
docs/…/get-file-download.mdShows original-content delivery through the download path and optional token access.
docs/…/get-file-view.mdShows original-content delivery for display without download behavior.
docs/…/get-file-preview.mdShows image preview generation and its presentation options.