我試圖通過HTML上傳文件上傳到S3,我試圖按照本教程:亞馬遜S3 CORS POST失敗,jQuery的文件上傳
http://pjambet.github.com/blog/direct-upload-to-s3/
我能張貼文件通過常規的HTML形式。但是,如果我發佈與JQuery-file-upload插件相同的表單,我會從亞馬遜獲得403。
這裏是我的形式:
<form accept-charset="UTF-8" action="https://youboox_dev.s3.amazonaws.com" enctype="multipart/form-data" class='direct-upload' method="POST">
<input type="hidden" name="key" value="test-file-name">
<input type="hidden" name="AWSAccessKeyId" value="AKIZ[...]YSCA">
<input type="hidden" name="acl" value="private">
<input type="hidden" name="success_action_status" value="201">
<input type="hidden" name="policy" value="<%= Facades::AmazonFacade.policy %>">
<input type="hidden" name="signature" value="<%= Facades::AmazonFacade.signature %>">
<input type="file" name="file">
<input type="submit" value="Load this file">
這裏是我的jQuery的上傳:
$('.direct-upload').fileupload({
url: $(this).attr('action'),
type: 'POST',
autoUpload: true,
dataType: 'xml',
add: function (event, data) {
jqXHR = data.submit();
}
我從亞馬遜這樣的回答:
OPTIONS https://youboox_dev.s3.amazonaws.com/ 200(OK)
POST https://youboox_dev.s3.amazonaws.com/ 403(禁止)
============================================= ===========
我很確定我的政策和簽名是正確的,因爲當我通過提交按鈕提交這個表單時,我得到了一個來自亞馬遜的好迴應,'不能下載我剛剛上傳的文件:
<PostResponse>
<Location>https://youboox_dev.s3.amazonaws.com/tottotoCVBNBV</Location>
<Bucket>youboox_dev</Bucket>
<Key>test-file-name</Key>
<ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag>
</PostResponse>