Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload to S3 from client or server?

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.

like image 449
lsimmons Avatar asked Sep 21 '16 18:09

lsimmons


1 Answers

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

like image 76
Pop-A-Stash Avatar answered Oct 11 '22 23:10

Pop-A-Stash