Home > other >  Opening pdf files from S3 bucket using a URL link
Opening pdf files from S3 bucket using a URL link

Time:09-28

I wonder if anyone can help. I'm currently working on a project where we have a load of pdf documents in an S3 bucket. What i would like to be able to do is to open the link to each pdf automatically, however the link to each document is:

enter image description here

This what each individual pdf property in S3 looks like:

enter image description here

if i click the Object URL link in the property section i get the following:

enter image description here

Is there something I need to change in the S3 bucket policy to get this to work? Any help or guidance would be greatly appreciated.

CodePudding user response:

It seems like you want a public S3 bucket (if fully public is not what you want, see the link towards the end). In order to make all objects public you must:

  • Navigate to the 'Permissions' tab of your bucket in the S3 console
  • Disable/uncheck 'Block public access (bucket settings)'
  • Add a statement to your bucket policy to allow getObject requests

Your bucket policy should look something like this:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*"
        }
    ]
}

After you do this, you should see the 'Publicly accessible' flags on your bucket and you'll be able to access objects with the object URL.

enter image description here

This article goes into more depth on object access.

  • Related