0
내가 HTML업로드는
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/aws-sdk/2.171.0/aws-sdk.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
AWS.config.update({accessKeyId: '', secretAccessKey: ''});
var s3BucketName = '';
var s3RegionName = 'US East (Ohio)';
function uploadFile() {
var s3 = new AWS.S3({params: {Bucket: s3BucketName, Region: s3RegionName}});
var file = document.getElementById('fileToUpload').files[0];
if (file) {
s3.putObject({Key: file.name, ContentType: file.type, Body: file, ACL: "public-read"},
function(err, data) {
if (data !== null) {
alert("Successful upload");
}
else {
alert("Upload failed");
}
});
}
}
</script>
</head>
<body>
<input type="file" id="fileToUpload"/>
<button onclick="uploadFile()">Upload to S3</button>
</body>
</html>
이 웹 페이지가 실패하고 이것이 내가 cors.html로 웹 페이지를 저장하고 열어 시도한 한 고르 규칙
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>http://*</AllowedOrigin>
<AllowedOrigin>https://*</AllowedOrigin>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
<ExposeHeader>Content-Range</ExposeHeader>
<ExposeHeader>Content-Encoding</ExposeHeader>
<ExposeHeader>Content-Length</ExposeHeader>
<ExposeHeader>Access-Control-Allow-Origin</ExposeHeader>
</CORSRule>
</CORSConfiguration>
입니다 업로드. 사용한 자격 증명을 제거했습니다. 같은 기원 정책 HTTPS에서 원격 자원 를 읽고 허용하지 : //*.s3.amazonaws 내가 S3
크로스 원산지 요청 차단에 고르 구성을 업데이트하는 경우에도
나는이 오류가 계속 .com/cors.html. (이유 : CORS 헤더 'Access-Control-Allow-Origin'이 누락되었습니다.)
어디서나 수신 업로드를 허용하도록 내 Cors 규칙을 업데이트 했더라도 오류가 계속 발생하는 이유는 무엇입니까?
allowedMethod을했다? 당신이's3.putObject ...'를하는 것처럼? – Edwin
PUT을 포함하도록 cors 규칙을 업데이트했지만 여전히 업로드 할 수 없습니다. – Gandalf
거기에 'HEAD'를 던질 수도 있습니까? – Edwin