image - 显示来自 Firebase 存储的图像时出现 404 错误

标签 image firebase http-status-code-403 firebase-storage

我想显示上传的图片,但即使我登录也出现 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);
});

最佳答案

使用此链接: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
});

关于image - 显示来自 Firebase 存储的图像时出现 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42303230/

相关文章:

.net - 如何在 .NET 中添加 EXIF 信息以对图像进行地理标记?

javascript - 错误类型错误 : Cannot read property 'flag' of undefined

ios - 从我的 NodeJS 应用程序发送推送通知消息不起作用

ios - Swift & Firebase - 在 Observe 之后调用一个函数

java - IIS 403 禁止在 URL 中使用 %2F

security - 有没有办法强制apache返回404而不是403?

html - 我的代码有什么问题? (试图创建一个 slider )

java - 如何根据元数据中的横向纵向信息禁用 html 中 img 的自动旋转?

Android:收到新通知时如何打开屏幕?

linux - 使用 .htaccess 重定向 403 错误