[英]Cors error while downloading image from S3
I am converting a div into an downloadable image. 我正在将div转换为可下载的图像。
function generateBanner() {
domtoimage.toBlob(document.getElementById('wrapper'))
.then(function(blob) {
console.log("blob", blob)
window.saveAs(blob, 'my-node.png');
});
}
This code works fine. 此代码可以正常工作。 My problem is when this div has an image that is hosted in a S3 Bucket 我的问题是,当该div的图像托管在S3存储桶中时
for example: 例如:
<article id="wrapper">
<p>{{ title }}</p>
<img class="logo" src="{{ logo }}" alt="">
<aside class="exclusive" ng-if="exclusive"></aside>
<aside class="off" ng-if="percentoff">{{ percentoff }}
</aside>
<div class="produtos">
<img src="https://s3-sa-east-1.amazonaws.com/teste-img-roge/Thumbs/0026954_30510_1_415.jpeg" alt="">
</div>
<aside class="valid" ng-if="valid"></aside>
</article>
after that, when I click I got CORS errors, and I have no idea why. 之后,当我单击时出现CORS错误,我也不知道为什么。
In my s3 Configuration I have this: 在我的s3配置中,我有以下内容:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
and still the same error. 并且仍然是相同的错误。 Any idea ? 任何想法 ? I tried few different configs in s3, and few approachs with javascript, but none of them worked. 我在s3中尝试了几种不同的配置,并使用javascript尝试了几种方法,但是没有一种有效。
You're missing <AllowedMethod>HEAD</AllowedMethod>
您缺少<AllowedMethod>HEAD</AllowedMethod>
Then you should see the following headers: 然后,您应该看到以下标题:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, HEAD, POST
Access-Control-Max-Age: 3000
Have in mind, that it could take a while before you see the correct headers. 请记住,可能需要一段时间才能看到正确的标题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.