1
我們的網站有一個問題,與鉻,從亞馬遜S3加載圖像與crossOrigin屬性設置在「匿名」。Cross Origin amazon S3 not working using chrome
我們S3服務器設置好的用:
`
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<ExposeHeader>x-amz-server-side-encryption</ExposeHeader>
<ExposeHeader>x-amz-request-id</ExposeHeader>
<ExposeHeader>x-amz-id-2</ExposeHeader>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
`
我使用canvg.js以創建從具有遠程圖像的SVG畫布(亞馬遜S3服務器)但Chrome瀏覽器返回「否訪問控制允許來源標題存在於請求的資源中。錯誤後執行該代碼:
this.img = document.createElement('img');
var self = this;
this.img.onload = function() { self.loaded = true; }
this.img.onerror = function() { if (typeof(console) != 'undefined')
console.log('ERROR: image "' + href + '" not found'); self.loaded = true; } }
if (svg.opts['useCORS'] == true) {
this.img.crossOrigin = 'Anonymous'; }
this.img.src = href;
在Firefox和IE瀏覽器這不會造成任何問題。
你「認爲」這不是S3設置的問題?你不應該發佈你的S3 CORS配置嗎? – 2014-10-01 15:12:16
我剛剛添加了它...我認爲這不是S3設置的問題,因爲在其他瀏覽器中它可以工作 – user3642612 2014-10-01 15:44:25