I am trying to write a handler for uploading files to node.js using express framework. Below is its original skeleton.
exports.handleUpload = function(req,res){
var temp_path = req.files.doc.path,
target_path = './uploads/' + req.files.doc.name ;
fs.rename(temp_path, target_path, function(err){
if(err){
console.log(err);
}
fs.unlink(temp_path, function(){
if(err){
console.log(err)
}
})
})
}
However, I sometimes get an error when executing the renmae function (not always), especially when downloading large files.
This is what the console caches from the error code
{ [Error: ENOENT, rename '/tmp/16368-19661hu.pptx'] errno: 34, code: 'ENOENT', path: '/tmp/16368-19661hu.pptx' }
From: https://github.com/joyent/node/blob/master/deps/uv/include/uv.h
XX(ENOENT, "no such file or directory")
The uploads / directory exists and permissions are not a problem. If this were the case, it would fail every time, but it is not.
source
share