minor cleanup

dev
Richard Girges 5 years ago
parent 1dcd6f7e74
commit cce078a89c
  1. 16
      lib/fileFactory.js
  2. 4
      lib/index.js

@ -48,12 +48,6 @@ module.exports = function(options, fileUploadOptions = null) {
});
}
/**
* Local function that moves the file to a different location on the filesystem
* Takes two function arguments to make it compatible w/ Promise or Callback APIs
* @param {Function} successFunc
* @param {Function} errorFunc
*/
function checkAndMakeDir(){
if (fileUploadOptions && fileUploadOptions.createParentPath) {
const parentPath = path.dirname(filePath);
@ -62,6 +56,13 @@ module.exports = function(options, fileUploadOptions = null) {
}
}
}
/**
* Local function that moves the file to a different location on the filesystem
* Takes two function arguments to make it compatible w/ Promise or Callback APIs
* @param {Function} successFunc
* @param {Function} errorFunc
*/
function moveFromTemp(successFunc, errorFunc) {
checkAndMakeDir();
fs.rename(options.tempFilePath, filePath, function(err){
@ -72,6 +73,7 @@ module.exports = function(options, fileUploadOptions = null) {
}
});
}
function moveFromBuffer(successFunc, errorFunc) {
checkAndMakeDir();
@ -89,8 +91,10 @@ module.exports = function(options, fileUploadOptions = null) {
}
}
};
if (options.size) {
output.size = options.size;
}
return output;
};

@ -10,7 +10,9 @@ const fileUploadOptionsDefaults = {
preserveExtension: false,
abortOnLimit: false,
createParentPath: false,
parseNested: false
parseNested: false,
useTempFiles: false,
tempFileDir: '/tmp'
};
/**

Loading…
Cancel
Save