Reputation: 9636
I have an express app where the users can upload photos. I am using node-formidable for handling the upload part. I also have node-graphicsmagick for doing manipulations on those photos like creating thumbnail, reading exif data. The node-formidable writes to a temporary file and so does node-graphicsmagick. I then upload the photos to S3 using knox.
My problem is I am not able to understand how to handle the temporary file after doing the upload to S3 using knox. I know if I don't handle it then it can cause problems but not being sure what to do?? Please help me.
Using streams is an option but I am not able to understand how to stream from node-formidable and node-graphicsmagick. Streaming is also a good option and I want to know if its possible.
Please help me. Thanks
Upvotes: 1
Views: 4138
Reputation: 11052
Just delete it:
var fs = require('fs');
var tmpFN = req.files.yourFieldName.meta.path;
fs.unlink(tmpFN, function(err){
if(err){ console.log(err); callback(err) }
else { callback(null) };
});
Upvotes: 3