3

I am working on an iOS app that will upload images and videos and save them per user. I was able to integrate amazon s3 and do the upload from the iOS app, I already have a node.js backend that I persist meta about the file that I saved in S3 and the S3 Id I get back from iOS. My question is : is this a good architecture, or should I move the S3 saving activity to the backend? how do other apps do it ( like instagram / vine ) should the mobile device handle that or the backend?

Thanks

Huang
  • 1,355
  • 2
  • 11
  • 28

1 Answers1

6

What you are doing is considered as the best practice : let the mobile devices upload directly and securely to S3.

Documentation :

You must ensure only your users can upload objects to S3 by crafting a correct IAM policy. Depending on how you authenticate your users, Cognito Identity might help to broker identity tokens received from third party providers (like Google, Facebook or Amazon) or your own (OpenID Connect Token) with AWS STS to receive a temporary Access Key and Secret Key.

Documentation :

Direct upload allows your application and your user base to scale without requiring additional compute power on the backend. S3 is a massively parallel object storage, it will handle your mobile fleet traffic, offloading you from low level tasks such as monitoring, scaling, patching,... your backend.

Now that Lambda is available (in Preview), you can also consider to capture meta data about the S3 object in a Lambda function and upload meta-data to your backend store (DynamoDB or a relational database) directly from lambda. Considering the generous free tier usage of Lambda, this solution would be much more cost effective than running your own backend. You are familiar with Node.JS, the framework used by Lambda, so their will be almost no learning curve for you.

Documentation:

Sébastien Stormacq
  • 14,301
  • 5
  • 41
  • 64
  • I kind of read the AWS documentation, but just wanted to a second opinion. so that means the Node.js layer will just handle metadata and never be heavy, which is something I want to have. As an additional question, Do you think that this architecture will work for any type of file? so lets assume the app will work like a dropbox kinda type, just saving user data, I make the app upload the file to S3, and get an ID and save it in Node.js? – Huang Nov 30 '14 at 01:24
  • Yes, it will work for any type of file. Restrictions are 5Gb for a single PUT operation. Files bigger than that must be send in HTTP Multipart form, up to 5TB per file which is the max for S3. See http://stackoverflow.com/questions/12980745/large-file-from-ec2-to-s3 for details. Once again, if consider this architecture, have a look at Lambda to collect your file meta-data ... there is no need of EC2 instances for this – Sébastien Stormacq Nov 30 '14 at 08:05