Reputation: 54949
I am uploading images to my S3 bucket via my Node.js Application. I have the following bucket policy.
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket_name/*"
}
]
}
When I go to the link of the file lets say its an image. It automatically downloads as a file and does not render in the browser. Any idea how to make it display in the browser without automatically force downloading the image in the browser?
Upvotes: 5
Views: 4173
Reputation: 18270
Explicitly set the Content-Type
of the object with image/<appropriate-subtype>
.
var params = { Bucket: '', Key: '', ContentType: 'image/png', ... }
The default Content-Type
would be application/octet-stream
, thus instead of rendering in the browser it is being downloaded.
Upvotes: 8