Jump to top

Task

interface

Storage Task used for Uploading or Downloading files.

Example 1

Get a Upload Storage task to upload a string:

const string = '{ "foo": 1 }';
const task = firebase
 .storage()
 .ref('/foo/bar.json')
 .putString(string);
Example 2

Get a Download Storage task to download a file:

const downloadTo = `${firebase.utils.FilePath.DOCUMENT_DIRECTORY}/bar.json`;

const task = firebase
 .storage()
 .ref('/foo/bar.json')
 .writeToFile(downloadTo);

Properties

snapshot

</>

Initial state of Task.snapshot is null. Once uploading begins, it updates to a TaskSnapshot object.

snapshot: null | TaskSnapshot;

Methods

cancel

</>

Cancel the current Download or Upload task.

cancel(): Promise<boolean>;

catch

</>
catch(onRejected: (a: NativeFirebaseError) => any): Promise<any>;

on

</>

Task event handler called when state has changed on the task.

on(event: "state_changed", nextOrObserver?: TaskSnapshotObserver | null | (a: TaskSnapshot) => any, error?: (a: NativeFirebaseError) => any | null, complete?: () => void | null): () => void;

pause

</>

Pause the current Download or Upload task.

pause(): Promise<boolean>;

resume

</>

Resume the current Download or Upload task.

resume(): Promise<boolean>;

then

</>
then(onFulfilled?: (a: TaskSnapshot) => any | null, onRejected?: (a: NativeFirebaseError) => any | null): Promise<any>;