Update tempFileHandler.js

Use path module to deal with paths to temp directory and temp files.
dev
Roman Burunkov 5 years ago committed by GitHub
parent c11471c68d
commit d864fe10f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      lib/tempFileHandler.js

@ -1,12 +1,13 @@
const fs = require('fs');
const path = require('path');
module.exports.tempFileHandler = function(options, fieldname, filename) {
const dir = options.tempFileDir || process.cwd() + '/tmp/';
const dir = path.normalize(options.tempFileDir || process.cwd() + '/tmp/');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
let tempFilePath = dir + 'tmp' + Date.now();
let tempFilePath = path.join(dir, 'tmp' + Date.now());
let writeStream = fs.createWriteStream(tempFilePath);
let fileSize = 0; // eslint-disable-line

Loading…
Cancel
Save