Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save banhaclong20/d7688fbe18464e3f638aba5404076142 to your computer and use it in GitHub Desktop.
Save banhaclong20/d7688fbe18464e3f638aba5404076142 to your computer and use it in GitHub Desktop.
Upload multiple files transactionally in Firebase Storage
// 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