storage library

Cloud Storage: objects as bytes, on the same app as Auth, Database and Firestore.

Downloads arrive as external typed data — the bytes are written once, into the buffer handed to the Dart heap, and never copied. That property is why this module is worth having over a REST call: a Database value is small enough that a copy is free, and an object is not.

Classes

StorageMetadata
What the backend knows about a stored object. Fields the backend did not set are null rather than empty: "no content type" and "the content type is the empty string" are different answers.

Properties

hasStorage bool
True when the library was built with Storage bound.
no setter

Functions

deleteObject(String path) Future<void>
Deletes the object at path.
downloadUrl(String path) Future<String>
A URL that serves the object at path, including its access token.
getObject(String path) Future<Uint8List>
Downloads the object at path.
initStorage() → void
Binds Storage to the app already initialized by initFirebase.
objectMetadata(String path) Future<StorageMetadata>
The metadata of the object at path, without downloading it.
putObject(String path, Uint8List bytes, {String? contentType}) Future<StorageMetadata>
Uploads bytes to path, answering with the stored object's metadata.
useStorageEmulator(String host, int port) → void
Points Storage at a local emulator, after initStorage and before the first operation — the SDK freezes the endpoint once a request has gone out.

Exceptions / Errors

StorageException
A Storage operation that failed, carrying the SDK's own code and message.