Created
August 23, 2021 08:01
-
-
Save phainamikaze/8b865c1ff030386a4cfdd3ca6be946ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require('fs'); | |
| async function example() { | |
| const client = new ftp.Client() | |
| client.ftp.verbose = true | |
| try { | |
| const secureOptions = { | |
| // Necessary only if the server requires client certificate authentication. | |
| key: fs.readFileSync('client-key.pem'), | |
| cert: fs.readFileSync('client-cert.pem'), | |
| // Necessary only if the server uses a self-signed certificate. | |
| ca: [ fs.readFileSync('server-cert.pem') ], | |
| // Necessary only if the server's cert isn't for "localhost". | |
| checkServerIdentity: () => { return null; }, | |
| }; | |
| await client.access({ | |
| host: "ftp.xxxx.xxxxx", | |
| user: "[email protected]", | |
| password: "xxxxxxx", | |
| secure :true, | |
| secureOptions : secureOptions | |
| }) | |
| await client.ensureDir("/my/remote/directory") | |
| console.log(await client.list()) | |
| await client.uploadFrom("temp/readme.txt", "readme.txt") | |
| // await client.downloadTo("README_COPY.md", "README_FTP.md") | |
| } | |
| catch(err) { | |
| console.log(err) | |
| } | |
| client.close() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment