firebase - 如何从 Firebase 存储访问图像?
问题描述
我想访问已上传到 Firebase 存储的图像。我已经尝试过他们在https://firebase.google.com/docs/storage/web/download-files中告诉我的内容,但它不起作用。
我想做的很简单。我有一个带有来源的“img”标签。使用 Vue.js,我想将上传的文件路径分配给图像源。
这就是我现在所拥有的:
loadImage(details) {
console.log(details.email);
var storage = firebaseApp.storage();
var gsReference = storage.refFromURL('gs://icachatdam.appspot.com/profilePics/jordi@test.com/profPic.png')
this.picture = gsReference.fullPath;
}
其中变量“图片”是图像源:
<q-img :src="this.picture" spinner-color="white" style="height: 140px; max-width: 150px" />
解决方案
感谢道格的回复,我已经测试了更多,这终于对我有用:
loadImage(details) {
var starsRef = firebaseApp.storage().ref().child('profilePics/'+details.email+'/profPic.png');
starsRef
.getDownloadURL()
.then(url => {
this.pictureURL = url;
//console.log(this.pictureURL);
});
}
推荐阅读
- python - 将图像 (JPEG) 转换为 PDF
- ipa - freeipa 从 v3 迁移到 v4
- python - 在 Python 中迭代的最佳对象类型
- javascript - 具有单个值的多个键名的 JSON 对象。我怎么读?
- google-app-engine - 将 webapp 连接到用户的 BigQuery 项目
- python - 为什么谷歌不推荐使用supervisord作为容器?在 kubernetes 中运行时,supervisord 是否能很好地处理 PID 1 问题?
- algorithm - 算法不是多项式递增
- html - 仅在将鼠标悬停在图像上时才会出现的图像上方文本
- batch-file - 无法在 Window cmd 的 If 块中将变量设置为另一个变量
- java - 将 byte[] 转换为 PDF 文件而不用 Java 保存在本地磁盘中