Forked from asciimike/firebase_storage_multi_file_upload.js
Created
February 18, 2018 21:16
-
-
Save iashris/dbebed5b7a6325f7299b0b17f9866148 to your computer and use it in GitHub Desktop.
Upload multiple files transactionally in Firebase Storage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set it up | |
firebase.storage().ref().constructor.prototype.putFiles = function(files) { | |
var ref = this; | |
return Promise.all(files.map(function(file) { | |
return ref.child(file.name).put(file); | |
})); | |
} | |
// use it! | |
firebase.storage().ref().putFiles(files).then(function(metadatas) { | |
// Get an array of file metadata | |
}).catch(function(error) { | |
// If any task fails, handle this | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment