1

I put a bucket policy so only users referred from a certain website would be able to access a certain PDF file in my Amazon S3 storage.

The file is set to private and the bucket policy seems to be working well, except for the fact that Chrome gets stuck on the loading page when opening the PDF file. However, I can download the PDF by right-clicking the link and saving it.

It also does this for IE but works well in Safari and Firefox. I tried clearing my cache and that didn't help.

Here's the bucket policy that I use:

{
"Version": "2012-10-17",
"Id": "http referer policy example",
"Statement": [
    {
        "Sid": "Allow get requests originated from www.example.com and example.com",
        "Effect": "Allow",
        "Principal": "*",
        "Action": "s3:GetObject",
        "Resource": "arn:aws:s3:::examplebucket/*",
        "Condition": {
            "StringLike": {
                "aws:Referer": [
                    "http://example.com/*",
                    "http://www.example.com/*"
                ]
            }
        }
    }
]
}

Thanks

denov
  • 11,180
  • 2
  • 27
  • 43
mzee99
  • 181
  • 1
  • 2
  • 12
  • Suspecting a CORS problem. Check if this thread helps: http://stackoverflow.com/questions/20253472/cors-problems-with-amazon-s3-on-the-latest-chomium-and-google-canary – Sony Kadavan Mar 02 '14 at 01:44

1 Answers1

2

I'm going to guess that the Content-Type response header isn't set correctly. It should be

Content-Type:application/pdf

You can see what is being sent in the network tab of the dev console. And you can set it in the metadata section of the properties for the file in the S3 console.

denov
  • 11,180
  • 2
  • 27
  • 43