Firebase从存储中获取下载图像的最佳方法是什么

时间:2020-06-08 02:45:21

标签: firebase google-cloud-firestore firebase-storage

当前正在考虑应该使用哪一个来从Google存储空间检索图像:

  1. 在前端使用getDownloadURL()
storageRef.child(`restaurants/${image_name}`).getDownloadURL()
  1. 上传图片时将下载网址保存到Firestore数据库中。这样您就可以从firebase.firestore().collection('restaurants').doc().get()通话中获取图片网址

  1. 在云功能中使用getSignedUrl()
firebase.firestore().collection('restaurants').doc().get()
...
var payload = doc.data()
bucket.file(`restaurants/${payload.image_name}`).getSignedUrl({
  action: 'read',
  expires: '01-01-2100'
})

帮助我确定最适合我的React项目的一个吗?

0 个答案:

没有答案