如何从火库商店下载图像。我正在使用vue-firestore

时间:2019-04-30 18:42:27

标签: firebase vue.js google-cloud-firestore

我将图像存储在firbase firestore中,并将数据存储在collection中。 我想在vue应用程序上使用图像检索数据,但是我无法获得下载图像URL。 如何从商店部分的vue firestore下载所有图像? 与关系。 例如 用户详细信息在collection文件夹中,个人资料图片在store部分中。 如何从商店部分下载个人资料图片,只需在vuejs中编写thr代码

我的单片预览代码在这里:

vuejs,firestore商店,vue-firestore实时

         const user= fb.auth().currentUser;
     return{
         Profile:db.collection("User_Profile/").doc(user.uid),


     }
 },
 methods:{

selectFile () {
     this.$refs.uploadInput.click()
   },
   detectFiles (e) {
     let fileList = e.target.files || e.dataTransfer.files
     Array.from(Array(fileList.length).keys()).map(x => {
       this.upload(fileList[x])
     })
   },
   upload (file) {
     this.fileName = file.name
     this.uploadTask = fb.storage().ref('UsedCar/' + file.name).put(file)
   },
   deleteImage(img,id){
       let image=fb.storage().refFromURL(img);
       this.allImages.splice(id,1);
       image.delete().then(res=>{

      Swal.fire('Deleted')
       }).catch(error=>{

       Swal.fire({
               type: 'error',
               title: 'Oops...',
               text: 'Something went wrong!',
               footer: '<a href>image Not Deleted</a>'
               })
       })

   }  
 },   
 watch: {
   uploadTask: function () {
     this.uploadTask.on('state_changed', sp => {
     },
     null,
     () => {
       this.uploadTask.snapshot.ref.getDownloadURL().then(downloadURL => {
         this.allImages.push(downloadURL);

       })
     })
   }
 }

}```

1 个答案:

答案 0 :(得分:0)

为此,您应该在Firebase实时数据库或Firestore中具有存储链接,以便使用Android中的内置下载管理器进行下载 否则,有一种方法可以下载存储空间中上传的文件