I have an array of image files that I loop over and convert each element (file) to a download url, which is basically a string.
So why do I get Unsupported field value: a custom File object
error when I try to push this array to Firestore.
Note: Not everytime I use set
it gives me an error. Sometimes it works, which is confusing too.
images.forEach((file, index) => {
const storageRef = firebase.storage().ref(`products/${uuid}.${fileExtenstion}`);
const task = storageRef.put(file);
task.on('state_changed',
function progress() {},
function error() {},
function complete() {
storageRef.getDownloadURL().then(url => {
imageFiles[index] = url;
})
}
)
})
firestore.collection('products').doc().set({
images: images
});