How do I show an image from my Amazon S3 on my website?

前端 未结 3 1756
孤独总比滥情好
孤独总比滥情好 2020-12-30 12:21

I have my pictures on Amazon S3. The pictures are private and not public so I can not show them with a direct link s3.amazonaws/bucket_name/key_name/image_name.jpg

3条回答
  •  执念已碎
    2020-12-30 13:04

    If you don't want to make your file public, here is the procedure.

    1. ensure your S3 bucket is private. Only authenticated and authorised calls are allowed to get your objects

    2. on the server side, when rendering the page, generate links to S3 object that include a signature. The signature will be computed from your access and secret key and will tell S3 that the call must be authorised

    S3 Signed URL are easy to generate from our SDK. For PHP, just check the doc at http://docs.aws.amazon.com/aws-sdk-php/guide/latest/service-s3.html#creating-a-pre-signed-url

    1. in the web page, when the user will click a signed URL, the browser will be directed to S3. S3 will verify the signature and - when correct - will get the object

提交回复
热议问题