304 for upload when all settings are public

0

hello,
this is my first time with aws.

i am trying to upload image from website to S3.
all my settings are public as fare as i understand, yet i get
Response {type: "cors", url: "https://s-cart-x.s3.eu-central-1.amazonaws.com/", redirected: false, status: 403, ok: false, …

the settings:

Permissions overview
Access
Public

Block all public access
Off
Block public access to buckets and objects granted through new access control lists (ACLs)
Off
Block public access to buckets and objects granted through any access control lists (ACLs)
Off
Block public access to buckets and objects granted through new public bucket or access point policies
Off
Block public and cross-account access to buckets and objects through any public bucket or access point policies
Off

Bucket policy
{
"Version": "2012-10-17",
"Id": "Policy1627561847500",
"Statement": [
{
"Sid": "Stmt1627561827637",
"Effect": "Allow",
"Principal": "",
"Action": "s3:GetObject",
"Resource": [
"arn:aws:s3:::s-cart-x/
",
"arn:aws:s3:::s-cart-x"
]
}
]
}

Object ownership
Object writer
The object writer remains the object owner.

Cross-origin resource sharing (CORS)
[
{
"AllowedHeaders": [
""
],
"AllowedMethods": [
"PUT",
"POST",
"GET",
"DELETE"
],
"AllowedOrigins": [
"http://localhost:3000"
],
"ExposeHeaders": []
},
{
"AllowedHeaders": [
"
"
],
"AllowedMethods": [
"PUT",
"POST",
"GET",
"DELETE"
],
"AllowedOrigins": [
"https://s-cart-x.herokuapp.com"
],
"ExposeHeaders": []
}
]

help.

已提问 3 年前265 查看次数
2 回答
0

this is what solve the trick... partially
(i cant believe amazon dont have a wizard to this.. but: )

i have changes the policy
{
"Version": "2012-10-17",
"Id": "Policy1627561847500",
"Statement": [
{
"Sid": "Stmt1627561827637",
"Effect": "Allow",
"Principal": "",
"Action": [
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetBucketLocation",
"s3:ListBucket",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::s-cart-x/
",
"arn:aws:s3:::s-cart-x"
],
"Condition": {
"StringLike": {
"aws:Referer": [
"https://shopping-cart-x.herokuapp.com/",
"http://localhost:3000/seller/NewProductScreen"
]
}
}
}
]
}

the issue now - is that the cors AllowedOrigins have to be AllowedOrigins:"*" ...
it fails with localhost:3000... or localhost:3000/myPath

已回答 3 年前
0

so this is the cors setting that fix the localhost for me

[
{
"AllowedHeaders": [
""
],
"AllowedMethods": [
"PUT",
"POST",
"GET",
"DELETE"
],
"AllowedOrigins": [
"http://localhost:3000"
],
"ExposeHeaders": [
"x-amz-server-side-encryption",
"x-amz-request-id",
"x-amz-id-2",
"Connection",
"ETag"
]
},
{
"AllowedHeaders": [
"
"
],
"AllowedMethods": [
"PUT",
"POST",
"GET",
"DELETE"
],
"AllowedOrigins": [
"https://s-cart-x.herokuapp.com/"
],
"ExposeHeaders": [
"x-amz-server-side-encryption",
"x-amz-request-id",
"x-amz-id-2",
"Connection",
"ETag"
]
}
]

so by now finly s3 is working....
it was a nightmer -

已回答 3 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则