Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use AWS S3 to store user uploaded pictures?

I am creating an iPhone app to allow users upload & share photos. Currently the photos uploaded are stored in my 1and1 cloud server I subscribed. Now I want to try AWS. I have subscribed a free tier AWS Linux EC2 and set up php/mysql. My question is, for scalability purpose, where should I store user pictures: EC2 or S3? And how to connect EC2 with S3 so user uploaded photos will be stored in S3? My understanding is that when user upload a photo to my EC2 instance, it is stored in EC2 and it will fill the space soon since I have only 5GB space.

With limited knowledge of AWS, my question may sound st**d but any help and advice will be appreciated!

like image 319
100calorie Avatar asked Aug 27 '12 19:08

100calorie


2 Answers

You should store your pictures in S3, data stored within your EC2 instances are not persistent. Use AWS SDK to upload data to S3.

like image 114
Michal Klouda Avatar answered Oct 09 '22 17:10

Michal Klouda


For this use case I would use S3.

The advantage of using S3 backing for your pictures is that you can easily use Amazon's Cloud Front CDN with S3 as the origin (you can also use your EC2 instance, but that involves more work).

And how to connect EC2 with S3 so user uploaded photos will be stored in S3

There is an S3 API for PHP

http://aws.amazon.com/sdkforphp/

like image 27
Eric J. Avatar answered Oct 09 '22 17:10

Eric J.