Skip to content

Instantly share code, notes, and snippets.

@MinecraftFuns
Last active December 7, 2019 12:06
Show Gist options
  • Save MinecraftFuns/17992d5d157c1da2e7e330c689a4d6f0 to your computer and use it in GitHub Desktop.
Save MinecraftFuns/17992d5d157c1da2e7e330c689a4d6f0 to your computer and use it in GitHub Desktop.
Example
import JSFtp from 'jsftp';
const ftp = new JSFtp({
host,
port,
});
ftp.raw(`user ${user}`, (err, {code}) => {
if (err) {
throw err;
}
if (code === 331) {
ftp.raw(`pass ${pass}`, (_err, {code}) => {
if (_err) {
throw _err;
}
if (code === 230) {
ftp.raw('type I', (__err) => {
if (__err) {
throw __err;
}
ftp.put(localFilPath, remoteFilePath, (___err) => {
if (___err) {
throw ___err;
}
ftp.raw('quit', (____err) => {
if (____err) {
throw ____err;
} else {
ftp.destroy();
}
});
})
});
} else {
throw _err;
}
});
} else {
throw err;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment