var AnyFile = require('any-file');
const sendFiles = require('any-file/lib');
var sf = new AnyFile();
var fromFile = "s3://BUCKET_NUM@s3.amazon.com/BUCKET_NAME/1.txt";
var toFile = "sftp://username:password@ec2_ip_addr.ap-south-1.compute.amazonaws.com:/1.txt";
//var toFile = "/home/user_name/Desktop/1.txt"; //s3 to on-premise is working
try {
sf.from(fromFile).to(toFile, function(err, res) {
console.log(res);
process.exit();
});
}
catch (err) {
console.log(err);
}
I'm using the 'any-file' npm library for transferring of files from AWS S3 bucket to EC2 VM, I have an SFTP server setup on my EC2, and the above code is running on my local machine.
But, when I'm sending file from s3 to ec2 the output is coming as true but file isn't getting copied, whereas while I'm trying to do the same but from s3 to local_machine output is coming true and file is getting copied successfully.