
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
ftp-simple
Advanced tools
If Node.js version is 8 or higher, use 0.3.0 or higher. Otherwise, use version 0.2.7.
Node.js version is 8 or higher
npm install ftp-simple
Otherwise
npm install ftp-simple@0.2.7
var FTP = require('ftp-simple');
var config = {
host: '',
port: 21,
username: '', //or user
password: '' //or pass
};
var ftp = FTP.create(config);
//ν΄λ λ³κ²½(directory change)
ftp.cd("/", function(err, path){});
//νμΌ or ν΄λ μμ (νμ νμΌ λ° ν΄λ ν¬ν¨)(file or directory remove(recursive))
ftp.rm("/filename", function(err){});
//ν΄λ μμ±(νμ ν΄λ ν¬ν¨ μμ±)(make directory)
ftp.mkdir("/directory", function(err){});
//νμΌ or ν΄λ μ΄λ νΉμ μ΄λ¦ λ³κ²½(file or directory move or change filename)
ftp.mv("/filename", "/newFilename", function(err, newPath){});
//ν΄λ λ΄ νμΌλͺ©λ‘ λ°ν(show files in directory)
ftp.ls("/directory", function(err, list){});
//ftp μλ²μμ νμ¬ μμ
κ²½λ‘ λ°ν(return server path)
ftp.pwd(function(err, path){});
//μλ²μ νμΌμ΄ μ‘΄μ¬νλμ§ μ¬λΆ λ°ν(boolean)
ftp.exist("/filename", function(exist){});
//νμΌ or ν΄λ μ
λ‘λ(file or directory upload)
ftp.upload("/test.txt", "/test.txt", function(err){}); //result => /test.txt
ftp.upload("/test.txt", "/test123.txt", function(err){}); //result => /test123.txt
ftp.upload("/test.txt", "/", function(err){}); //result => /test.txt
ftp.upload("/directory", "/", function(err){}); //result => /directory
//Array - Object({local:'localPath', remote:'remotePath'})
var arr = [{local:"/test.txt", remote:"/test.txt"}, {local:"/test1.txt", remote:"/abcd/test2.txt"}, {local:"/directory", remote:"/"}];
ftp.upload(arr, function(err){}); // 2 arguments;
/* result
/test.txt
/abcd/test2.txt
/directory
*/
//Array - String
var arr = ["/test.txt", "/abcd/test2.txt", "/directory"];
ftp.upload(arr, "/", function(err){}); // 3 arguments;
/* result
/test.txt
/abcd/test2.txt
/directory
*/
//Array - Object and String
var arr = [{local:"/test.txt", remote:"/directory/test.txt"}, "/abcd/test2.txt", "/directory"];
ftp.upload(arr, "/", function(err){}); // 3 arguments;
/* result
/directory/test.txt
/abcd/test2.txt
/directory
*/
//νμΌ or ν΄λ λ€μ΄λ‘λ(file or directory download)
ftp.download("/test.txt", "/test.txt", function(err){}); //result => /test.txt
ftp.download("/test.txt", "/test123.txt", function(err){}); //result => /test123.txt
ftp.download("/test.txt", "/", function(err){}); //result => /test.txt
ftp.download("/directory", "/", function(err){}); //result => /directory
//Array - Object({local:'localPath', remote:'remotePath'})
var arr = [{remote:"/test.txt", local:"/test.txt"}, {remote:"/test1.txt", local:"/abcd/test2.txt"}, {remote:"/directory", local:"/"}];
ftp.download(arr, function(err){}); // 2 arguments;
/* result
/test.txt
/abcd/test2.txt
/directory
*/
//Array - String
var arr = ["/test.txt", "/abcd/test2.txt", "/directory"];
ftp.download(arr, "/", function(err){}); // 3 arguments;
/* result
/test.txt
/abcd/test2.txt
/directory
*/
//Array - Object and String
var arr = [{remote:"/test.txt", local:"/directory/test.txt"}, "/abcd/test2.txt", "/directory"];
ftp.download(arr, "/", function(err){}); // 3 arguments;
/* result
/directory/test.txt
/abcd/test2.txt
/directory
*/
//μ μ μ’
λ£(disconnect)
ftp.close();
create(< object >config)
tls.connect()
in Node.js.[Node.js version is 8 or higher]
Please refer to 'https://www.npmjs.com/package/basic-ftp' if this is 'ftp' and 'https://www.npmjs.com/package/ftp' if it is 'ftp2'. The 'secure' option is available regardless of 'type'. The default is 'ftp'.
[Otherwise]
Please refer to 'https://www.npmjs.com/package/jsftp' if this is 'ftp' and 'https://www.npmjs.com/package/ftp' if it is 'ftp2'. The 'secure' option is available for 'ftp2'. The default is 'ftp'.
cd(< string >path, < function >callback) - Changes the working directory. callback has 1 parameter: < Error >err.
rm(< string >path, < function >callback) - Deletes a file or directory(include child files) path on the server. callback has 1 parameter: < Error >err.
mkdir(< string >path, < function >callback) - Creates a new directory recursive. callback has 1 parameter: < Error >err.
mv(< string >oldPath, < string >newPath, < function >callback) - Renames or Move oldPath to newPath on the server. callback has 2 parameter: < Error >err, < String >newPath.
ls(< string >path, < function >callback) - Retrieves the directory listing of path. callback has 2 parameter: < Error >err, < Array >list.
pwd(< function >callback) - Retrieves the current working directory. callback has 2 parameters: < Error >err, < string >cwd.
exist(< function >callback) - whether a file or direcotry exists. callback has 1 parameters: < boolean >exist.
upload(< mixed >localPath, < string >remotePath, < function >callback) - Sends data to the server to be stored as remotePath. If direcotry path, include self directory and child files. If you want only child files, localPath is "/directory/**". callback has 1 parameter: < Error >err.
download(< mixed >remotePath, < string >localPath, < function >callback) - Retrieves a file or directory at path from the server. If directory path, include child files. callback has 1 parameter: < Error >err.
close() - Closes the connection to the server after any/all enqueued commands have been executed.
open(< FTPClient >client) - Emitted when connection and authentication were sucessful.
close - Emitted when the connection has fully closed.
error(< Error >err) - Emitted when the connection has fully closed.
upload(< string >uploadedRemotePath) - Emitted when file or directory uploaded.
download(< string >downloadedLocalPath) - Emitted when file or directory downloaded.
//Connect
var FTP = require('ftp-simple');
var config = {
host: '',
port: 21,
username: '', //or user
password: '' //or pass
};
var ftp = FTP.create(config);
/*
Ex) Directory structure
/test/test.txt
/test/child1
/test/child1/image.png
/test/child1/child2
/test/child1/child2/shell.sh
*/
//Case1. files Upload
//"/test/test.txt", "/test.txt" or "/test/test.txt", "/"
ftp.upload("/test/test.txt", "/test.txt", function(err){
ftp.close();
});
/* result
/test.txt
*/
//Case2. child files Upload
// '/test/**' or '/test/*'
ftp.upload("/test/**", "/", function(err){
ftp.close();
});
/* result
/test.txt
/child1
/child1/image.png
/child1/child2
/child1/child2/shell.sh
*/
//Case3. directory Upload
ftp.upload("/test", "/", function(err){
ftp.close();
});
/* result
/test/test.txt
/test/child1
/test/child1/image.png
/test/child1/child2
/test/child1/child2/shell.sh
*/
//Case4. Multi file Upload
//Array - Object({local:'localPath', remote:'remotePath'})
var arr = [{local:"/test.txt", remote:"/test.txt"}, {local:"/test1.txt", remote:"/abcd/test2.txt"}, {local:"/directory", remote:"/"}];
ftp.upload(arr, function(err){ftp.close();}); // 2 arguments;
/* result
/test.txt
/abcd/test2.txt
/directory
*/
//Array - String
var arr = ["/test.txt", "/abcd/test2.txt", "/directory"];
ftp.upload(arr, "/", function(err){ftp.close();}); // 3 arguments;
/* result
/test.txt
/abcd/test2.txt
/directory
*/
//Array - Object and String
var arr = [{local:"/test.txt", remote:"/directory/test.txt"}, "/abcd/test2.txt", "/directory"];
ftp.upload(arr, "/", function(err){ftp.close();}); // 3 arguments;
/* result
/directory/test.txt
/abcd/test2.txt
/directory
*/
//Case5. file download
//"/test/test.txt", "/test.txt" or "/test/test.txt", "/"
ftp.download("/test/test.txt", "/test.txt", function(err){
ftp.close();
});
/* result
/test.txt
*/
//Case6. direcotry download
ftp.download("/test", "/", function(err){
ftp.close();
});
/* result
/test/test.txt
/test/child1
/test/child1/image.png
/test/child1/child2
/test/child1/child2/shell.sh
*/
//Case7. Multi file download
//Array - Object({local:'localPath', remote:'remotePath'})
var arr = [{remote:"/test.txt", local:"/test.txt"}, {remote:"/test1.txt", local:"/abcd/test2.txt"}, {remote:"/directory", local:"/"}];
ftp.download(arr, function(err){ftp.close();}); // 2 arguments;
/* result
/test.txt
/abcd/test2.txt
/directory
*/
//Array - String
var arr = ["/test.txt", "/abcd/test2.txt", "/directory"];
ftp.download(arr, "/", function(err){ftp.close();}); // 3 arguments;
/* result
/test.txt
/abcd/test2.txt
/directory
*/
//Array - Object and String
var arr = [{remote:"/test.txt", local:"/directory/test.txt"}, "/abcd/test2.txt", "/directory"];
ftp.download(arr, "/", function(err){ftp.close();}); // 3 arguments;
/* result
/directory/test.txt
/abcd/test2.txt
/directory
*/
FAQs
simple ftp
The npm package ftp-simple receives a total of 0 weekly downloads. As such, ftp-simple popularity was classified as not popular.
We found that ftp-simple demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Β It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.