update file upload error handling docs

This commit is contained in:
Nicolas Beck 2017-06-27 20:41:13 +02:00 committed by GitHub
parent 43410bbadd
commit 946736b0c9
1 changed files with 9 additions and 7 deletions

View File

@ -34,18 +34,20 @@ firebase.storage()
### Listen to upload state
```javascript
const unsubscribe = firebase.storage()
const uploadTask = firebase.storage()
.ref('/files/1234')
.putFile('/path/to/file/1234')
.on('state_changed', snapshot => {
.putFile('/path/to/file/1234');
const unsubscribe = uploadTask.on('state_changed', snapshot => {
//Current upload state
}, err => {
//Error
unsubscribe();
}, uploadedFile => {
}, null, uploadedFile => {
//Success
unsubscribe();
});
uploadTask.catch(err => {
//Error
unsubscribe();
});
```
## Downloading files