const fs = require('fs');

module.exports.tempFileHandler = function(options, fieldname, filename) {
  const dir = options.tempFileDir || process.cwd() + '/tmp/';

  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir);
  }
  let tempFilePath = dir + 'tmp' + Date.now();
  let writeStream = fs.createWriteStream(tempFilePath);
  let fileSize = 0; // eslint-disable-line

  return {
    handler: function(data) {
      writeStream.write(data);
      fileSize += data.length;
      if (options.debug) {
        return console.log( // eslint-disable-line
          `Uploaded ${data.length} bytes for `,
          fieldname,
          filename
        );
      }
    },
    getTempFilePath: function(){
      return tempFilePath;
    },
    cleanupStream: function(){
      writeStream.end();

      fs.unlink(tempFilePath, function(err) {
        if (err) throw err;
      });
    },
    complete: function(){
      writeStream.end();
    }
  };
};

@@ -18,16 +18,46 @@
 e('fs');
+%0Aconst path = require('path');
 %0A%0Amodule
@@ -138,16 +138,31 @@
 t dir = 
+path.normalize(
 options.
@@ -199,16 +199,17 @@
  '/tmp/'
+)
 ;%0A%0A  if 
@@ -284,13 +284,22 @@
 h = 
+path.join(
 dir
- +
+,
  'tm
@@ -313,16 +313,17 @@
 te.now()
+)
 ;%0A  let 

Update tempFileHandler.js