Upload Files

You can upload files to a remote server via SSH.

Usage

uploadFiles(<properties>)
let properties = {
    {Object} [sshConfig] - Connection Configurations. (more info: https://www.npmjs.com/package/node-ssh)
    {Array Object} [files] - Command to run on remote server
    {number} [timeout] - Timeout - default: 30 seconds.    
}
tests/sample1.js
/* LIBRARIES
*************/
const { sente } = require('#libraries');
const { execCommand } = sente;

/* TEST FLOW
*************/
test = async () => {
   
    // SSH config
     let sshConfig = {
        host: '1.1.1.1' ,
        username: '<username>',
        password: '<password>',
    };
    
    let files=[
        {local: './file1.txt' , remote: '/home/user/file1.txt'},
        {local: './file2.zip' , remote: '/home/user/file2.zip'},
        {local: './file3.doc' , remote: '/home/user/file3.doc'},
    ];
    
    
    // Upload Files
    await ssh.uploadFiles({files: files, sshConfig: sshConfig, timeout:45})  

Last updated