Amazon S3 For Photo Storage

Amazon S3 For Photo Storage

Amazon S3 Services

Store the original size in S3. Run a web server that can generate any desired size from the original image on request. Stick a CDN (CloudFront) in front of the web server. Now, your web site or application can request a URL like /16x16/someimage.jpg from CloudFront.

  1. Amazon S3 stores data as objects within buckets. An object consists of a file and optionally any metadata that describes that file. To store an object in Amazon S3, you upload the file you want to store to a bucket. When you upload a file, you can set permissions on the object and any metadata.
  2. How to set up, configure and backup to Amazon S3 storage and then use the Amazon S3 credentials to set up a connection profile and backup to the cloud service.
  3. Actually, with a SmugMug account you can opt to use it as a 'FrontEnd' for S3 storage as well. For any 'normal' photo on SmugMug you can also upload any number of 'vault' photos that get stored on S3 (under your S3 account) and are tied to that photo, kinda like a.
  4. Amazon S3 is designed to provide 99% durability and 99.99% availability over a given year for your cloud storage needs. Amazon S3 offers low, pay-as-you-go pricing, so businesses only pay for the storage they use. Plus, getting started with AWS is fast. You can sign-up and start storing your files in a matter of minutes.

This article demonstrates how to use the AWS SDK for Android to uploadan image to Amazon Simple StorageService (S3) from your mobile device and how to make that imageavailable on the web. Amazon S3 is storage for the Internet. It's a simplestorage service that offers software developers a highly-scalable,reliable, secure, fast, and inexpensive data storage. The complete samplecode and project files are included in the AWS SDK for Android which canbe found here.

To use the AWS SDK for Android, you will need your AWS credentials,that is, your Access Key ID and Secret Access Key. If you haven'talready signed up for Amazon WebServices (AWS), you will need to do that first to get your AWScredentials. You can sign up for AWS here.

Here's what the sample app looks like at start up on Android:

Photo Upload

The app uses each platform's 'image picker' utility to have theend-user select an image for upload. The app then creates an Amazon S3client, uses the client to create an Amazon S3 bucket in which to storethe image, and finally uploads the image into the bucket. A bucket is acontainer for objects stored in Amazon S3. Every object--such as animage--is contained within a bucket.

Get the image

The first step is to retrieve the content, in this case an image, tobe uploaded to Amazon S3. For this sample app, selecting an image from thedevice itself is an easy choice.

Once an image is selected, a callback method is invoked with theselected image's information. The app uses this information to completethe upload.

Upload the image

Once we have the image, we can attempt to upload it to Amazon S3.

First, create an Amazon S3 client to communicate withthe service.

Second, create an Amazon S3 bucket to store thepicture.

Finally, put the image object into the Amazon S3bucket.

Browser Display

The app makes the image available for viewing in a browser bygenerating a pre-signed URL. A pre-signed URL is a URL for an Amazon S3resource that is signed with current AWS security credentials. Thepre-signed URL can then be shared with other users, allowing them toaccess resources without providing an account's AWS securitycredentials.

First, create an override content type to ensure thatthe 'content' will be treated as an image by the browser.

SecondPlex eve echoes. , create the pre-signed URL request. Pre-signedURLs can be created with an expiration date, that is, a date andtime after which the resource will no longer be available. In the sample,the pre-signed URLs are valid for only one hour.

Third, generate the pre-signed URL.

Finally, launch the browser to view the pre-signed URLwhich will display the image.

Next Steps

These few lines of code demonstrate how Amazon S3 could become alimitless storage device for your mobile photos. A photo sharing app thatallows users to view photos from other users would not be a difficultextension to the above code. Also, the content that is uploaded and sharedis not limited to images. The content could be audio files, video files,text, or other content that users want to store and share.


A sample app that includes this code is provided with both mobile SDKs.The download links can be found here: AWS SDK for Android.

For more information about using AWS credentials with mobileapplications see the following article: Authenticating Users of AWS Mobile Applications with a Token VendingMachine


StorageAmazon S3 For Photo Storage

Please feel free to ask questions or make comments in the MobileDevelopment Forum.

Amazon S3 Reviews

Portions of this page are reproduced from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.