How do I display protected Amazon S3 images on my secure site using PHP?

前端 未结 4 2094
太阳男子
太阳男子 2021-01-30 17:39

I am trying to move images for my site from my host to Amazon S3 cloud hosting. These images are of client work sites and cannot be publicly available. I would like them to be d

4条回答
  •  天命终不由人
    2021-01-30 18:16

    When you talk about security and protecting data from unauthorized users, something is clear: you have to check every time you access that resource that you are entitled to.

    That means, that generating an url that can be accessed by anyone (might be difficult to obtain, but still...). The only solution is an image proxy. You can do that with a php script.

    There is a fine article from Amazon's blog that sugests using readfile, http://blogs.aws.amazon.com/php/post/Tx2C4WJBMSMW68A/Streaming-Amazon-S3-Objects-From-a-Web-Server

    readfile('s3://my-bucket/my-images/php.gif');
    

提交回复
热议问题