Javascript Angular/JS将图像上载到AWS预签名URL
每次我尝试将图像上传到预先签名的url时。我收到飞行前警告,上传失败 我需要做什么 据我所知,我应该上传到可以在图像的url属性中看到的url 我尝试了各种各样的方法,但这是我当前的上传代码:Javascript Angular/JS将图像上载到AWS预签名URL,javascript,angularjs,amazon-web-services,Javascript,Angularjs,Amazon Web Services,每次我尝试将图像上传到预先签名的url时。我收到飞行前警告,上传失败 我需要做什么 据我所知,我应该上传到可以在图像的url属性中看到的url 我尝试了各种各样的方法,但这是我当前的上传代码: $.ajax({ type: 'PUT', url: pData.url, // Content type must much with the parameter you signed your URL with contentType: 'binary
$.ajax({
type: 'PUT',
url: pData.url,
// Content type must much with the parameter you signed your URL with
contentType: 'binary/octet-stream',
// this flag is important, if not set, it will try to send data as a form
processData: false,
// the actual file is sent raw
data: $scope.file
})
.success(function() {
alert('File uploaded');
})
.error(function() {
alert('File NOT uploaded');
console.log( arguments);
});
我如何解决这个问题,我无法访问提供签名url的后端,是否有可能是负责人或亚马逊的CORS错误,我如何检查
谢谢您的建议。这是CORS问题。您需要请求管理员将其放入S3存储桶的CORS配置中
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
*
得到
放
邮递
删除
*
这是CORS问题。您需要请求管理员将其放入S3存储桶的CORS配置中
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
*
得到
放
邮递
删除
*
您对此有何回应?我也面临同样的问题。谢谢你得到回应了吗?我也面临同样的问题。谢谢