如何将多个图像上载到Firebase存储并返回多个下载URL

如何将多个图像上载到Firebase存储并返回多个下载URL,firebase,vue.js,google-cloud-firestore,firebase-storage,Firebase,Vue.js,Google Cloud Firestore,Firebase Storage,我们正在开发一个简单的电子商务应用程序,需要上传多个产品图片。使用Vuejs和Vue Croppa,我们需要将图像上载到firebase存储,检索下载URL,然后在将该产品添加到数据库时将这些URL包含在一个数组中 <croppa v-for="(c, i) in croppas" :key="i" v-model="croppas[i]" :width="150" :height="150" @new-image="croppas.push({})" v-show

我们正在开发一个简单的电子商务应用程序,需要上传多个产品图片。使用Vuejs和Vue Croppa,我们需要将图像上载到firebase存储,检索下载URL,然后在将该产品添加到数据库时将这些URL包含在一个数组中

<croppa v-for="(c, i) in croppas"
  :key="i"
  v-model="croppas[i]"
  :width="150"
  :height="150"
  @new-image="croppas.push({})"
  v-show="i === croppas.length - 1 || c.imageSet"
></croppa>
现在,我们得到一个控制台错误:

Firebase Storage: Invalid argument in 'put' at index 0: Expected Blob or File.

另外,
productImageUrl=downloadURL
只适用于一个文件,其中可能有更多文件。如何使用阵列使其工作?

关于您的第二期

为要上载的每个图像设置承诺

因此,在您的循环中调用一个与下面“类似”的方法(我刚刚从我的一个项目中获取了这个):


第二期

为要上载的每个图像设置承诺

因此,在您的循环中调用一个与下面“类似”的方法(我刚刚从我的一个项目中获取了这个):

Firebase Storage: Invalid argument in 'put' at index 0: Expected Blob or File.
uploadImageAsPromise (imageFile) {
    const self = this;

        return new Promise(function (resolve, reject) {
            var storageRef = firebase.storage().ref("/imagestestnew/"+imageFile.name);

            //Upload file
            var task = storageRef.put(imageFile);


            //Update progress bar
            task.on('state_changed',
                function progress(snapshot){

                    var percentage = snapshot.bytesTransferred / snapshot.totalBytes * 100;
                    console.log("percentage" + percentage)
                    self.progressUpload = percentage;
                },
                function error(err){
                    console.log("error")
                },
                function complete(){
                    console.log("done")
                    var downloadURL = task.snapshot.downloadURL;
                }
            );
        });
}