Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Support SCP Buffer Rather Than Local File #89

Open
jthomerson opened this issue Apr 1, 2017 · 1 comment
Open

Support SCP Buffer Rather Than Local File #89

jthomerson opened this issue Apr 1, 2017 · 1 comment

Comments

@jthomerson
Copy link

I would like to be able to pass in a buffer rather than a file path as the first argument to scp. This would allow me to SCP files from AWS S3 (or elsewhere - something I generate in-memory) without needing to write it to a temporary file.

@onebytegone
Copy link
Contributor

@jthomerson While a little more verbose than passing a Buffer directly to the scp function, the code snippet below should provide the desired behavior. The low level API allows for copying data from a Buffer, see write under Methods.

var scpClient = require('scp2'),
    client;

client = new scpClient.Client({
   host: 'example.com',
   username: 'your-user',
   password: '******'
});

client.write({
   destination: 'target.txt',
   content: new Buffer('hello world\n')
}, function(err) {
   client.close();
   if (err) {
      throw err;
   }
});

Note: The docs on write are not completely correct as it will not take a string for content, an error will be thrown from lib/client.js#L228.

Expansion of the scp API to allow for running the following would be nice:

var scpClient = require('./lib/scp');

scpClient.scp(
   new Buffer('hello world\n'),
   'admin:password@example.com:port:/home/admin/target.txt',
   function(err) {
      if (err) {
         throw err;
      }
   }
);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants