Node.JS fs.rename not working

Renaming a file in Debian Wheezy does not work using fs.rename or fs.renameSync.

This only happens in files moved from / tmp / to another location.

Reported error: EXDEV, interconnect not allowed.

+5
source share
2 answers

Debian Wheezy by default uses tmpfs for the / tmp folder.

This can be disabled by changing / etc / default / rcS.

RAMTMP=yes

should be set to

RAMTMP=no
0
source

This is another solution that works for me:

var fs = require("fs"),
util = require('util');
...
//fs.renameSync(files.upload.path, "/tmp/test.png");

var readStream = fs.createReadStream(files.upload.path)
var writeStream = fs.createWriteStream("/tmp/test.png");

util.pump(readStream, writeStream, function() {
    fs.unlinkSync(files.upload.path);
});
+2
source

All Articles