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
error
</>If the TaskSnapshot#state
is error
, returns a JavaScript error of the
current task snapshot.
error: NativeFirebaseError;
state
</>The current state of the task snapshot.
state: "cancelled" | "error" | "paused" | "running" | "success";