0

So im playing around with rabbitMQ and using node for consumers, I am trying to pull an image file down from a remote server, this works fine as long as I am using './' as the destination, but as soon as I use something like 'c:\images' it bombs with:

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

I have also used '\images' with the same results

user.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;
devilsansclue
  • 179
  • 1
  • 9
  • Create a less localized version because SCP has nothing at all to do with this error, http://stackoverflow.com/q/20417118/124486 – Evan Carroll Dec 06 '13 at 06:05

1 Answers1

9

found the answer. I'm a dummy head. forgot the trailing slash, it was trying to write the file over the directory rather than put the file IN the directory

devilsansclue
  • 179
  • 1
  • 9