Tuesday, 25 April 2017

Cleaning temporary files after file upload with restify

I am building a node storage server with restify. I am processing uploads via restify.bodyParser, which under the hood uses formidable.

Formidable stores files in os.tmpDir() by default, and I need to change that to some other folder, and so I did via restify.bodyParser({uploadDir: '/path/to/new/tmp'}).

The problem is that those temporary files are kept in the tmp directory even after I finish processing the request.

I have seen this question (Handling Temporary Files after upload), that supposes to just delete the tmp file after processing it.

My question is, do you need to always manually remove the file? Even with the default os.tmpDir() directory? How does the default system tmp folder work? Does it flush itself sometimes?



via Martin Adámek

No comments:

Post a Comment