Reputation: 9244
I have been struggling in the last few days to get this working.
Basically I have a form in HTML that has a type="file"
input.
I would like that this file is sent to nodejs and directly streamed to Amazon s3. In this way I will use less storage on my server (imagine if 100 people upload 1g, at the end my server will have 100g), so if I stream I will occupy just memory for a little amount of time
Any hint on how to do this with express?
Upvotes: 1
Views: 2146
Reputation: 5480
I am unsure if you're looking for a CORS approach, where the user uploads directly to your S3 bucket, or an approach where you use express as a middle-man.
If you're looking at a CORS approach (which I would recommend unless you are doing anything special with the file before it gets put in S3 that can't be done client side), this should help you out: http://bencoe.tumblr.com/post/30685403088/browser-side-amazon-s3-uploads-using-cors
If you are planning to use your server as a mid-point (ie, upload to your server, then upload from your server to S3), I have heard good things about Knox (https://github.com/LearnBoost/knox). I've played around with it, but haven't actually used it as I tend to use CORS approaches.
Upvotes: 1