This class will help you do more complex things with jsftp.
You can:
- Create a folder with subfolders
- Remove a folder and its' subfolders/files
- Remove a single file
- Get the list-information of a folder using
ls
- Renaming a folder or a file
- Cut a file to a directory
1. Install jsftp:
npm i jsftp
2. Download the file jsftp_simplify.js
3. Change
this.config
in the constructor()
function so it point to your server 4. Require jsftp_simplify:
const jsftp_simplify = require('path/to/jsftp_simplify');
Creating a new folder:
jsftp_simplify.makeDir('folderName')
Creating a new folder or an existing folder with subfolders:
jsftp_simplify.makeDir('folderName/subfolderName/subfolderName')
Removing a folder and its' subfolders/files:
jsftp_simplify.removeDir('path/to/folderName')
Removing a single file:
jsftp_simplify.removeFile('path/to/fileName')
Get the list-information of a folder:
jsftp_simplify.ls('path/to/folderName')
Returns an array of objects containing {name: string, size: Number, isFolder: boolean}
Renaming a folder or a file:
jsftp_simplify.rename({ path: 'path/to/folderOrFilename', name: 'newName' })
Cut a file to a directory:
jsftp_simplify.xcopy({ from: 'path/to/fileName', to: 'new/path' })
Some functions are not implemented (e.g. upload, download). Feel free to implement new functions. I'll not add new feature, however, if any issue occur I'll try to fix them. If you have any questions about JSftp-simplify, just pm me!
See License