Jump to top

TaskSnapshot

interface

A TaskSnapshot provides information about a storage tasks state.

Example 1
firebase
  .storage()
  .ref('/foo/bar.json')
  .putString(JSON.stringify({ foo: 'bar' }))
  .then((taskSnapshot) => {
    if (taskSnapshot.state === firebase.storage.TaskState.SUCCESS) {
      console.log('Total bytes uploaded: ', taskSnapshot.totalBytes);
    }
  });
Example 2
const task = firebase
  .storage()
  .ref('/foo/bar.json')
  .putString(JSON.stringify({ foo: 'bar' }));

task.on('state_changed', taskSnapshot => {
  if (taskSnapshot.state === firebase.storage.TaskState.PAUSED) {
    console.log('Resuming my task!');
    task.resume();
  }
});

Properties

bytesTransferred

</>

The number of bytes currently transferred.

bytesTransferred: number;

error

</>

If the TaskSnapshot#state is error, returns a JavaScript error of the current task snapshot.

metadata

</>

The metadata of the tasks via a FullMetadata interface.

metadata: FullMetadata;

ref

</>

The Reference of the task.

ref: Reference;

state

</>

The current state of the task snapshot.

state: "cancelled" | "error" | "paused" | "running" | "success";

task

</>

The parent Task of this snapshot.

task: Task;

totalBytes

</>

The total amount of bytes for this task.

totalBytes: number;