mardi 30 décembre 2014

Best way to view specific private images from Amazon S3 in a gallery?

I am using fineuploader to upload photos to Amazon S3. I am saving the generated image-name in a mySQL database on my web site hosting. The image-names are related to a user in the database (users in the database should only be able to see their own images). Before I used Amazon S3, I had a queue where I was looking up related images to a user in the database and returned an array return $query->fetchAll();. I have the following code in my view that loops through the array and display the images.



<?php foreach ($images as $img) { ?>
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<div class="thumbnail">
<a href="<?php echo URL . 'album/deleteimage/' . htmlspecialchars($img->image_id, ENT_QUOTES, 'UTF-8'); ?>"><button class="close" type="button" >×</button></a>
<img style="height:130px;" class="img-responsive" src="<?php if (isset($img->image_name)) echo htmlspecialchars(URL . 'img/uploads/' . $img->image_name, ENT_QUOTES, 'UTF-8'); ?>">
</div>
</div>
<?php } ?>


How do I do this with Amazon S3? If I change all my uploaded photos to the public (instead of the default private) on Amazon S3 can I still use my old code. Just change SRC in the IMG-tag to



s3.amazonaws/bucket_name/key_name


But I guess it is preferable to (still) have the images private om Amazon S3.





Aucun commentaire:

Enregistrer un commentaire