S3にファイルをアップロードするためのオプションを検討しました。 S3静的なWebホスティングを使用して見ている1つのオプション。このオプションでは、アップロードオプション付きの単純なIndex.htmlページを作成しようとしているページがあります。私は、次のバケットポリシーを設定します。AWS S3静的ウェブホスティングを使用してS3にファイルをアップロード
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Allow Public Access to All Objects",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::<bucketname>/*"
}
]
}
次は、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>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
私はS3にアクセスしようとすると、次のIndex.htmlと
<html>
<header><title>Hello World</title></header>
<body>
Hello world
<form action="/action_page.php">
<input type="file" name="pic" accept="image/*">
<input type="submit">
</form>
</body>
</html>
のコードですウェブホスティングURIを持つバケット、私はページを取得しています。ドキュメントをアップロードしようとすると、次のエラーが表示されます。
404 Not Found
Code: NoSuchKey
Message: The specified key does not exist.
Key: action_page.php
RequestId: <requestid>
HostId: <hostid>
An Error Occurred While Attempting to Retrieve a Custom Error Document
Code: NoSuchKey
Message: The specified key does not exist.
Key: error.html
エラーページを表示するerror.htmlページを追加するとエラーページが表示されます。
これで、S3 Webホスティングを使用してファイルをバケットにアップロードすることは、コーディングなしで正しい方法ですか?私はここで何が欠けていますか?