Bucket Setup
Public Bucket
If you want to allow public access to your uploaded files, create your S3 bucket with a public access policy. Here's an example of a public access policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicRead",
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject"],
"Resource": ["arn:aws:s3:::YOUR_BUCKET_NAME/*"]
}
]
}
Private Bucket
You do not need to create a public access policy if you want to keep your bucket private.
You only have to set privateBucket
to true
in your API route in generatePresignedUrls()