Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function example() {
- var finalData = '';
- const client = new ftp.Client()
- client.ftp.verbose = true
- try {
- await client.access({
- host: "XXXX",
- user: "XXXX",
- password: "XXXX",
- })
- await client.upload(fs.createReadStream("README.txt"), myFileNameWithExtension)
- //let writeStream = fs.createWriteStream('/tmp/' + myFileNameWithExtension);
- //await client.download(writeStream, myFileNameWithExtension)
- finalData = await (() => {
- return new Promise((resolve, reject) => {
- writeStream
- .on('finish', () => {
- // Create a global variable to be used outside of the FTP function scope to pipe the txt content into another node mogule
- })
- .on('error', (err) => {
- console.log(err);
- reject(err);
- })
- })
- })();
- }
- catch (err) {
- console.log(err)
- }
- client.close();
- return finalData;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement