Reputation: 3091
Hello, until today I was uploading a single picture to the storage having a progress bar, something that works fine.
Now, I need to upload albums of multiple images. I thought this would be something similar but iterating... What I am doing is:
1. Create a blob for each image in the albun
2. Upload them one by one to the storage.
The problem is that if I upload them one by one multiple uploadTasks will be created, and I need only one progress bar. Is there any way to upload multiples images at once?
const { images, description, location, tags } = postInfo; // images is an array of images' uris
// TODO - Build the blobs (for each image in images)
// TODO - Post UUID = Firt Blob UUID
// Create a storage referece
const storageRef = firebase.getStorage().ref("photos").child(postId);
// TODO - Upload all blobs to storage
// const uploadTask = storageRef.put(blob); <----------- Not only a blob, just all the album
uploadTask.on("state_changed", (taskSnapshot) => { // How to get a unique uploadTask for all blobs??
// Update progress bar
const percent =
(taskSnapshot.bytesTransferred / taskSnapshot.totalBytes) * 100;
setUploadProgress(percent);
});
Upvotes: 0
Views: 120
Reputation: 466
It seems like you will need to run multiple async functions at the same time. Try this flow
Thank you for the question. It was a fun one.
Upvotes: 2