尝试使用获取获取图像,图像存储在firebase存储中

时间:2020-01-19 03:21:34

标签: reactjs firebase firebase-storage

嗨, 我正在尝试使用提取API获取图像,该URL是有效的,因为当我将图像URL放入Img标记时,它可以正常工作。

我的提取功能:

   getImage = () => {  
   const url= "https://firebasestorage.googleapis.com/v0/b/alpha-c790f.appspot.com/o/images%2Frivers.jpg?alt=media&token=6a96d672-23c1-425f-bdca-47f6d73608f0"


fetch(this.state.url,{
  mode: 'no-cors'
}).then(response => response.blob())
.then((res)=>{
     console.log(res);
    var objectURL = URL.createObjectURL(res);
    var myImage = new Image();
    myImage.src = objectURL;

}).catch(err=>{
  console.log(err);
})
}

firebase云存储访问规则:

      rules_version = '2';
      service firebase.storage {
      match /b/{bucket}/o {
           match /{allPaths=**} {
           allow read, write: if request.auth != null;
           }
        }
    }

我想像这样实现它,因为我想在它上面放一个微调器,直到图像出现为止。

我得到的答复是这个

           Blob {size: 0, type: ""}
                 size: 0
                 type: ""
            __proto__: Blob

0 个答案:

没有答案