MZH*_*MZH 6 javascript jquery amazon-s3
我试图从浏览器的文件上传到亚马逊S3,我已经修改了CORS策略规则允许后挖斗,但我得到的错误
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidArgument</Code><Message>Bucket POST must contain a field named 'key'. If it is specified, please check the order of the fields.</Message>
<ArgumentValue></ArgumentValue><ArgumentName>key</ArgumentName><RequestId>1E0A8DC78C0CEA9A</RequestId><HostId>XN38Qje9hUrGqHNIhtT8CtowX9tXlpyfEoaXb1UNxlsyLOWreh2mKqKVXg1zjLVl</HostId></Error>
Run Code Online (Sandbox Code Playgroud)
这是我的请求和响应,我仍然通过仍然收到此错误以正确的顺序传递关键参数


任何人都可以告诉我它有什么问题,我正在使用FormData提交请求
任何帮助将不胜感激.
谢谢
编辑:这是代码请检查
var form_data = new FormData();
form_data.append('file',hdlr.file);
//form_data.append('crop_type',settings.get_cropped_type());
//form_data.append('attributes',JSON.stringify(file_attr));
$('input:hidden',$form).each(function(){
form_data.append(this.name,this.value);
});
//finally post the file through AJAX
var xhr = new XMLHttpRequest();
xhr.open("POST", $form[0].action, true);
xhr.send(form_data);
Run Code Online (Sandbox Code Playgroud)

Ray*_*lus 27
看起来您的文件表单字段首先出现在请求中.我无法确定,因为您没有在答案中包含整个请求有效负载,但看起来它出现在"key"字段的正上方.AWS会在文件字段后忽略请求中的所有字段,因此所有其他字段必须出现在文件之前.
| 归档时间: |
|
| 查看次数: |
6189 次 |
| 最近记录: |