在這個非常相關的問題(Upload directly to Amazon S3 using Plupload HTML5 runtime)中提到,amazon現在允許使用HTML5上傳CORS,但任何人都可以成功配置plupload以使用'html5'運行時將文件推送到s3?對相關問題的迴應不提供任何實施細節。如何使用'html5'運行時直接執行plupload到s3?
這是我目前的plupload配置:
$("#uploader").plupload({
// General settings
runtimes: 'html5,flash',
url: 'http://s3.amazonaws.com/' + $('#Bucket').val(),
max_file_size: '20mb',
multipart: true,
multipart_params: {
'key': '${filename}', // use filename as a key
'Filename': '${filename}', // adding this to keep consistency across the runtimes
'acl': $('#Acl').val(),
'Content-Type': 'binary/octet-stream',
'success_action_status': '201',
'AWSAccessKeyId': $('#AWSAccessKeyId').val(),
'policy': $('#Policy').val(),
'signature': $('#Signature').val()
},
file_data_name: 'file',
multiple_queues: true,
filters: [
{ title: "Image files", extensions: "jpg,png,gif,jpeg" }
],
flash_swf_url: '/Scripts/plupload/plupload.flash.swf',
});
上面的代碼是工作的「閃光」運行,從而產生的政策和正確簽名。
我是否缺少multipart_params配置對象中的任何參數?
此外,我用我的S3桶以下CORS配置:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
我是否需要進行任何其他配置更改S3存儲允許從「HTML5」 plupload運行CORS上傳?
的CORS你使用的配置看起來也很好。我看起來就像那樣。 – sunnymtn
明白了。謝謝你們的幫助。 – njebert
@sunnymtn你能告訴我完整的代碼嗎?我沒有看到你將如何實現你提供給代碼njebert所顯示的代碼。 – SReca