如何从 firebase 存储访问图像?
How to access an image from firebase storage?
我想访问我上传到 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;
}
其中变量"picture"是图片来源:
<q-img :src="this.picture" spinner-color="white" style="height: 140px; max-width: 150px" />
问题可能出在这里:
<q-img :src="this.picture" spinner-color="white" style="height: 140px; max-width: 150px" />
而不是这个,写
<q-img :src="picture" spinner-color="white" style="height: 140px; max-width: 150px" />
让我知道这是否适合您。如果没有,我再考虑一下。
多亏了 Doug 的回复,我进行了更多测试,这终于对我有用了:
loadImage(details) {
var starsRef = firebaseApp.storage().ref().child('profilePics/'+details.email+'/profPic.png');
starsRef
.getDownloadURL()
.then(url => {
this.pictureURL = url;
//console.log(this.pictureURL);
});
}
我想访问我上传到 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;
}
其中变量"picture"是图片来源:
<q-img :src="this.picture" spinner-color="white" style="height: 140px; max-width: 150px" />
问题可能出在这里:
<q-img :src="this.picture" spinner-color="white" style="height: 140px; max-width: 150px" />
而不是这个,写
<q-img :src="picture" spinner-color="white" style="height: 140px; max-width: 150px" />
让我知道这是否适合您。如果没有,我再考虑一下。
多亏了 Doug 的回复,我进行了更多测试,这终于对我有用了:
loadImage(details) {
var starsRef = firebaseApp.storage().ref().child('profilePics/'+details.email+'/profPic.png');
starsRef
.getDownloadURL()
.then(url => {
this.pictureURL = url;
//console.log(this.pictureURL);
});
}