Skip to content

feat(storage): add downloadStream for streaming file downloads#1580

Merged
spydon merged 5 commits into
mainfrom
lukasklingsbo/storage-download-stream
Jul 11, 2026
Merged

feat(storage): add downloadStream for streaming file downloads#1580
spydon merged 5 commits into
mainfrom
lukasklingsbo/storage-download-stream

Conversation

@spydon

@spydon spydon commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds StorageFileApi.downloadStream, which returns the response body as a lazy Stream<Uint8List> for memory-efficient handling of large files instead of buffering the whole body into a Uint8List (as download does). The request is sent when the stream is listened to, and a non-success status surfaces as a StorageException on the stream before any bytes are emitted, matching how File.openRead behaves.

  • downloadStream(path, {transform, queryParams, cacheNonce}) returns Stream<Uint8List>
  • Internal Fetch.getStream streaming GET, an async* generator marked @internal
  • download and downloadStream share a new private _downloadUri builder (DRY)

Outcome: implemented
Reference: supabase-js download(...).asStream() (StreamDownloadBuilder)
Compliance matrix: storage.file_buckets.download_as_stream -> implemented

Notes

  • Idiomatic Dart choices rather than a transliteration of the JS builder: a bare lazy Stream<Uint8List> (not Future<Stream<List<int>>> and not a chained asStream() builder), with errors delivered on the stream. Uint8List is used for the byte chunks, consistent with download; because Stream is covariant it is still usable anywhere a Stream<List<int>> is expected.
  • Unit tests cover the streamed happy path, the transform plus cacheNonce query, and an error status surfacing on the stream.

Stacking

Third of three stacked PRs. Base: #1579 (listPaginated). Review and merge #1578 then #1579 first.

Adds an optional cacheNonce parameter to getPublicUrl, createSignedUrl,
createSignedUrls and download, appending a cacheNonce query parameter to
the generated URL to bypass CDN caching for a specific file version.

Ref: SDK-875
@spydon spydon requested a review from a team as a code owner July 10, 2026 12:13
@github-actions github-actions Bot added the storage This issue or pull request is related to storage label Jul 10, 2026
Adds StorageFileApi.listPaginated, backed by the storage list-v2 endpoint,
supporting cursor-based pagination and hierarchical (delimiter) listing via
PaginatedSearchOptions and returning a PaginatedListResult of PaginatedFile
and PaginatedFolder entries.

Implements storage.file_buckets.list_files_paginated.
@spydon spydon force-pushed the lukasklingsbo/storage-list-v2 branch from dc28e71 to 5653c6a Compare July 10, 2026 12:23
@spydon spydon force-pushed the lukasklingsbo/storage-download-stream branch from aa3d02e to 5bc78e5 Compare July 10, 2026 12:24
Adds StorageFileApi.downloadStream, returning the response body as a
Stream<List<int>> for memory-efficient handling of large files instead of
buffering into a Uint8List. A non-success response throws a StorageException
before the stream is returned.

Implements storage.file_buckets.download_as_stream.
@spydon spydon force-pushed the lukasklingsbo/storage-download-stream branch from 5bc78e5 to 1b049ee Compare July 10, 2026 12:32
Base automatically changed from lukasklingsbo/storage-list-v2 to main July 11, 2026 14:54
@spydon spydon merged commit 8b839a1 into main Jul 11, 2026
29 checks passed
@spydon spydon deleted the lukasklingsbo/storage-download-stream branch July 11, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage This issue or pull request is related to storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants