Dear all, I'm having trouble storing my media collection to an S3 bucket. I followed the instructions on the github repo.
these are my configurations:
- media collections:
https://github.com/oliviervd/cms-studios/blob/main/src/collections/Media.ts
- payload config :
https://github.com/oliviervd/cms-studios/blob/main/src/payload.config.tsHave you received any errors in the console that could be helpful?
The IAM creds for your S3 bucket user - have they received sufficient permission to store data in your bucket? And have you made sure the correct bucket name is written in the permissions for the IAM role?
Also, you may need to put the region on the configuration as well.
i've added a security policy to the user; still doesn't work though.
what does the forcePathStyle do? Is it needed.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "
","
]
}
]
}
in the console I'm getting a 404: not found error. I'm guessing my path isn't correct?
forcePathStyle
allows you to change how you fetch images again. Could be useful in cases where you have maybe fastly cdn or a custom image service proxy.
Is the record created in Payload?
yes it all works fine, it just doesn't store the file anywhere it seems.
If you look in your S3 bucket through AWS management console - you don't see it there neither?
no I checked
do I need to use the user ARN as endpoint perhaps?
I created a custom policy for an IAM user with following:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObjectAcl",
"s3:GetObject",
"s3:PutBucketAcl",
"s3:ListBucket",
"s3:DeleteObject",
"s3:GetBucketAcl",
"s3:GetBucketLocation",
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::<bucket-name>",
"arn:aws:s3:::<bucket-name>/*"
]
}
]
}
May be a permissions issue
Also note the asterisk here
"arn:aws:s3:::<bucket-name>/*"
Also looks like you have too many colons here
S3://bucket-name/ would this be the endpoint?
no
or do i need it like this;
https://s3.region-code.amazonaws.com/bucket-name/key-name
ok i guess that's the issue 🙂
S3_ACCESS_KEY_ID="IAM_ACCESSKEY"
S3_SECRET_ACCESS_KEY="IAM_SECRET_ACCESS_KEY"
S3_BUCKET="bucket-name"
S3_REGION="eu-west-2"
S3_ENDPOINT="
https://s3.eu-west-2.amazonaws.com"
Ok that resolved the issue. Everything works fine now! Thank you for your patience and help 🙂
Most welcome bud
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.