Skip to content Skip to sidebar Skip to footer

Asynchronous Multiple Photos Upload With Firebase

Can anyone help me please. I have a problem uploading multiple photos with Firebase. My problem is that when I loop through the photos to be uploaded the UploadTask seems to work o

Solution 1:

I can give you an for the algorithm (just answered it for JS):

// set it up
firebase.storage().ref().constructor.prototype.putFiles = function(files) { 
  var ref = this;
  returnPromise.all(files.map(function(file) {
    return ref.child(file.name).putFile(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
});

You can use the Android Tasks.whenAll (docs, blog post) to do a similar thing: create an array of tasks, then use a whenAll() to kick them off.

Post a Comment for "Asynchronous Multiple Photos Upload With Firebase"