I'm trying to copy pdf and/or word documents from one folder into another. The code below works sometimes, but then other times it does not.
app.post('/api/file_archive/:file_name', function (req, res) {
var file_name = req.params.file_name;
var src = 'public/uploads/files' + file_name;
var dest = 'archived_files/files';
if(file_name != "") {
console.log("Entered fs access");
fs.access(dest, function(err) {
if(err)
fs.mkdirSync(dest);
copyFile(src, path.join(dest, file_name));
res.json({ message: 'file archived!'});
});
};
});
I'm currently receiving this error:
{ Error: ENOENT: no such file or directory, open 'C:\Users\duquetr\Documents\maize-and-blue-brief\public\uploads\files\1495121011192_Letter of Rec for RJ.pdf' at Error (native) errno: -4058, code: 'ENOENT', syscall: 'open', path: 'C:\\Users\\duquetr\\Documents\\maize-and-blue-brief\\public\\uploads\\files\\1495121011192_Letter of Rec for RJ.pdf' }
I've searched around a bit and I can't seem to find anything that pertains to why this code sometimes works.
Thanks for your help!
via Ronald Duquette
No comments:
Post a Comment