i'm trying move uploaded file /tmp
home
directory using nodejs/expressjs:
fs.rename('/tmp/xxxxx', '/home/user/xxxxx', function(err){ if (err) res.json(err); console.log('done renaming'); });
but didn't work , no error encountered. when new path in /tmp
, work.
im using ubuntu, home
in different partition. fix?
thanks
yes, fs.rename not move file between 2 different disks/partitions. correct behaviour. fs.rename
provides identical functionality rename(2)
in linux.
read related issue posted here.
to want, have this:
var source = fs.createreadstream('/path/to/source'); var dest = fs.createwritestream('/path/to/dest'); source.pipe(dest); source.on('end', function() { /* copied */ }); source.on('error', function(err) { /* error */ });
Comments
Post a Comment