Ad

Amazon S3 Image Hosting With Shopify

I have an AWS S3 bucket that I store product images on. I sell on multiple sales channels and use ChannelAdvisor to share all my product data to all the different sites. My image URLs are sent via ChannelAdvisor to the sites. Amazon reads my images fine, my website on Shopify does not read the images at all.

I think it's because how the images are shared. If you put the image URL in your browser, it downloads the image, but I want it to just show the image in the browser. I think this is my problem with Shopify.

Below is my current AWS policy, my question is how do I change the policy or shared URLs to make AWS load in the browser not download the image?

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::mybucket-name/*"
        }
    ]
}
Ad

Answer

This is not a function of policy, but rather one of metadata. Browsers use the Content-Type response header to determine what kind of file is coming in, and how to handle it. For example, for a .png file, the content type needs to be set to image/png. You set this when uploading the files to S3.

Ad
source: stackoverflow.com
Ad