5

Should I upload my files to S3 directly from the client or send them back to my server and upload them from there?

What are the pros and cons of each method? Which is more commonly done?

I'm using the MEAN stack, if that is relevant.

lsimmons
  • 677
  • 1
  • 8
  • 22
  • Well there are no any pros or cons as such? The only I can think of is if you send that file to your server and then to S3 it will slow down the upload functionality. What are you trying to achieve using your stack – Piyush Patil Sep 21 '16 at 18:48
  • I assume since you have a stack that if your upload goes directly from the client to S3 that you will still have a server running? Do you have any other relevant requirements or architectural constraints? – jzonthemtn Sep 21 '16 at 18:49
  • Yes it's a full stack app with a server running. The only constraints or requirement that comes to mind is that I would like access to my S3 buckets to only be through my app - so I don't want a user to be able to take credentials and upload a bunch of files outside of the app. – lsimmons Sep 21 '16 at 19:14
  • I'm really just looking for best practices here since I'm just starting with S3. Is one method more common than the other? Why? Thanks! – lsimmons Sep 21 '16 at 19:15

1 Answers1

10

You can create signed upload URLs with the Amazon API. This will prevent unregistered users from uploading things to your bucket(s).

Your server creates the signed URL and returns this to the client. The client can then upload directly to S3 without bogging down the server. You will probably also want to use Amazon notification service to notify the server when the upload is completed so that you can update the database with the location of the newly saved upload.

Check out this question about how to
upload file from angularjs directly to amazon s3 using signed url

Community
  • 1
  • 1
Pop-A-Stash
  • 6,572
  • 5
  • 28
  • 54