|
|
|
@ -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; |
|
|
|
|
}; |
|
|
|
|