数字海洋空间上传:对飞行前请求的响应未通过访问控制检查修复

时间:2018-11-15 08:16:26

标签: amazon-s3 cors xmlhttprequest digital-ocean

使用预签名的URL方法将文件从浏览器(javascript)上传到Spaces帐户。它已被阻止

Access to XMLHttpRequest at 'https://my/signed/url' from origin 'http://192.168.1.233:8000' has been blocked by CORS policy: Response to the preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

XMLHttpRequest

var blob = new Blob([e.target.files[0]], {type: e.target.files[0].type});
var xhr = new XMLHttpRequest();
xhr.open('PUT', data.upload_url);
xhr.send(blob);
console.log(xhr.status)

更新了Spaces设置中的CORS配置(主机,最大年龄和允许的方法),但仍然引发CORS标头问题。我实际上在这里想念的是什么。在python请求中也是如此,

Python请求:

with open(archive_file, 'rb') as data:
        response = requests.put(signed_uri, data=data)

$.ajax()作为文件索引发送甚至失败。谁能建议我如何从javascript上载而不使用nodejsreact

0 个答案:

没有答案