我想显示上传的图片,但即使我登录也遇到403错误。 上传工作很好,downloadURl没问题。 我已经通过身份验证(上传成功显示我已经签名) 但是我无法显示上传的图片。
storage.child(file_name).put(event_image).then(function(snapshot) {
console.log('Uploaded a blob or file!');
var img_src = snapshot.downloadURL;
$('img#uploaded').attr('src',img_src);
});
答案 0 :(得分:0)
使用此链接:https://firebase.google.com/docs/storage/web/download-files#download_data_via_url
storageRef.child('images/stars.jpg').getDownloadURL().then(function(url) {
// `url` is the download URL for 'images/stars.jpg'
// This can be downloaded directly:
var xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function(event) {
var blob = xhr.response;
};
xhr.open('GET', url);
xhr.send();
// Or inserted into an <img> element:
var img = document.getElementById('myimg');
img.src = url;
}).catch(function(error) {
// Handle any errors
});