gpt4 book ai didi

node.js - 出现错误 : EISDIR when trying to write scp'd file to directory

转载 作者:太空宇宙 更新时间:2023-11-04 02:49:22 24 4
gpt4 key购买 nike

所以我在玩rabbitMQ并为消费者使用 Node ,我试图从远程服务器上拉取一个图像文件,只要我使用'./'作为目的地,这就可以正常工作,但是一旦我使用'c:\images'之类的东西,它就会崩溃:

{ [Error: EISDIR, open 'C:\images'] errno: 28, code: 'EISDIR', path: 'C:\\images' }

我也使用了“\images”,得到了相同的结果

用户.moveImage.js:

var amqp = require('amqp'),
cxn = require('./cxn.js'),
env = require('./env.js'),
argv = require('optimist').argv,
fs = require('fs'),
client = require('scp2');

var path = env.local.path;
if(argv.env != undefined) {
path = env[argv.env].path
} else {
console.log('Undefined or invalid environment, using local');
}

var connection = amqp.createConnection({ url: cxn.connectionUrl() });

// Wait for connection to become established.
connection.on('ready', function () {
// Use the default 'amq.topic' exchange
connection.queue('user.image.move', {
durable: true,
autoDelete: false
},function(q){
// Catch all messages
q.bind('#');

// Receive messages
q.subscribe(function (message) {
console.log(message);
//scp the file from the remote to the local imagePath
fs.readdir(env.local.imagePath,function(err, files){
console.log(files);
});
client.scp({
host: message.host,
username: '#######',
password: '#################',
path: message.webroot + message.image_url
}, env.local.imagePath, function(err) {console.log(err)})

});
});
});
connection.on('error',function(e){
console.log(e);
})

env.js:

var local = 
path: 'C:\\Users\\ian\\Documents\\sites\\townspot\\app\\webroot',
mediaPath: 'C:\\media',
imagePath: 'c:\\images'
}

exports.local = local;

最佳答案

找到了答案。我是个假头。忘记了尾部斜杠,它试图将文件写入目录而不是将文件放入目录中

关于node.js - 出现错误 : EISDIR when trying to write scp'd file to directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18777302/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com