问题描述
我有一个联系人列表,每个人都有一个存储在Firebase存储中的个人资料照片。获取图片的官方方式是使用Firebase存储SDK获取网址,并将其设置为img元素中的src。
I have a list of contacts and each of those has a profile photo which is stored in Firebase storage. An official way of getting the images would be to fetch the URL using the Firebase storage SDK and set it as src in img element.
firebaseApp.storage().ref("profilePhotos/" + officeId + ".jpg").getDownloadURL().then(function (url) {
this.photoUrl = url;
}.bind(this)).catch(function (error) {
console.log("Photo error"); // TODO: handler
});
当我不得不加载多个文件时(如联系人列表),这非常麻烦。收到的文件网址是静态的吗?我可以将它存储在数据库中的配置文件信息,并直接使用它?
This is quite cumbersome when I have to load multiple files (as in contact list). Is the file URL received above static? Can I store it in the database in the profile information and use it directly?
谢谢
Thanks
推荐答案
一个非常常见的模式是将文件的下载URL存储在实时数据库中,以便以后使用。下载网址应该可以工作,直到您选择。
A very common pattern is to store the download URL of a file in Realtime Database for easy use later on. Download URLs should work until you choose to revoke them.
这篇关于Firebase存储网址是静态的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!