我试图从火力地堡存储下载网址的图像。要做到这一点我创造了这个代码:
ngOnInit(): void {
const imageUrl = 'https://firebasestorage.googleapis.com/v0/b/heimatvoll-1785b.appspot.com/o/Blogs%2FBasic%20Blog%20Banner%2Fcook-366875_1280.jpg?alt=media&token=bb08b895-55c4-404d-aedc-1a77fceacf74';
this.http.get(imageUrl, {
responseType: ResponseContentType.Blob
})
.toPromise()
.then((res: any) => {
const blob = new Blob([res._body], {
type: res.headers.get('Content-Type')
});
const urlCreator = window.URL;
this.imageData = this.sanitizer.bypassSecurityTrustUrl(
urlCreator.createObjectURL(blob));
});
}
如果我的网址更改为从谷歌的图片或其他任何东西它的工作,但“正常”的网址,如果我使用的存储URL我收到此错误:
Error错误:“未捕获(在承诺):网址0:与状态响应空”