Question

I am interested in creating a static file server that accepts binary image data and a file name, writing the image to disk.

There are tons of static file server solutions in Node for retrieving static files (express.static, connect.static, node-static) but I've found none built to also accept data. Should I write this functionality or do you know of any existing solutions?

Any suggestions would greatly appreciated.

Was it helpful?

Solution

You want to use multiparty to handle uploads. (Connect and therefore Express use multiparty internally when you use the bodyParser() or multipart() middleware.)

You can set the autoFile option to true and multiparty will automatically store received files in a folder of your choosing (uploadDir). You can also manually pipe the upload stream to some other destination (ie S3 or GridFS or whatever).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top