我有jquery fine-uploader 5.2.1,我这样配置了
<script type="text/javascript">
$(function() {
$('#fineUploader').fineUploaderS3({
template: 'qq-template',
request: {
endpoint: "https://MY-BUCKET.s3.amazonaws.com",
accessKey: "MY-AWS-KEY",
},
signature: {
endpoint: "/s3demo-cors.php"
},
uploadSuccess: {
endpoint: "index.html"
},
chunking: {
enabled: true,
mandatory: true,
}
});
});
</script>
我有s3demo-cors.php,我只修改了这两行
$clientPrivateKey = 'MY AWS SECRET KEY';
$expectedBucketName = "MY-BUCKET";
在检查流程时,我可以看到签名生成正确,然后OPTIONS请求成功完成,但随后发出此请求并导致来自amazon的403 InvalidAccessKeyId响应。
POST /8fbc7973-d054-41aa-a2af-f9c9d29569f0.jpg?uploads HTTP/1.1
Host: MY-BUCKET.s3.amazonaws.com
Connection: keep-alive
Content-Length: 0
x-amz-acl: private
Origin: https://MY-HOST
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36 FirePHP/4Chrome
Content-Type: image/jpeg
Authorization: AWS MY-AWS-KEY:SIGNATURE
x-amz-meta-qqfilename: beautiful_scenery-1024x768.jpg
x-amz-date: Fri, 08 May 2015 15:02:58 GMT
Accept: */*
Referer: https://MY-HOST/fineuploader/index.html
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
X-FirePHP-Version: 0.0.6
X-Wf-Max-Combined-Size: 261120
我的CORS文件中有以下内容
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<ExposeHeader>ETag</ExposeHeader>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
我几乎被困在这一点上,并会欣赏任何有关如何进一步调试的见解。
谢谢!
更新1
如果它有帮助,对于单个请求,这些是我要求签名的标题
POST
image/jpeg
x-amz-acl:private
x-amz-date:Fri, 08 May 2015 15:19:52 GMT
x-amz-meta-qqfilename:beautiful_scenery-1024x768.jpg
/MY-BUCKET/bedbba49-ae0c-479d-b7a0-663bbd55cc53.jpg?uploads
这些是发出的
POST /bedbba49-ae0c-479d-b7a0-663bbd55cc53.jpg?uploads HTTP/1.1
Host: MY-BUCKET.s3.amazonaws.com
Connection: keep-alive
Content-Length: 0
x-amz-acl: private
Origin: https://MY-HOST
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36 FirePHP/4Chrome
Content-Type: image/jpeg
Authorization: AWS MY-KEY:SIGNATURE
x-amz-meta-qqfilename: beautiful_scenery-1024x768.jpg
x-amz-date: Fri, 08 May 2015 15:19:52 GMT
Accept: */*
Referer: https://MY-HOST/fineuploader/index.html
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
X-FirePHP-Version: 0.0.6
X-Wf-Max-Combined-Size: 261120