Monday, 13 March 2017

Send an array of files using the scp1 module to a remote server in node js

I've been trying to use npm's scp1 module to send files to a remote server of mine. And I've been able to use it for a single file, but I need to do that for multiple files. So the send function is a promise from what I can understand. I've tried using the async module but I haven't had much luck since I've only seen examples with callback functions as opposed to promises. Here's what I have so far

sendFile(file_path, file_name).then(function (response) {
                       //fs.unlinkSync(file_path)
                       console.log("sent file");
                   }).catch(function (error) {
                       console.log(error);
                   });

Every way I've tried so far only sends the first file when I try to do the same thing for an array of files. I just want to be able to use this same function to send multiple files from an array.



via Tracy Ann Monteiro

No comments:

Post a Comment