humy2833 / easy-ftp Goto Github PK
View Code? Open in Web Editor NEWnode.js module
node.js module
I cant connect to sftp server
var ftp = new easyftp();
ftp.connect({
host:'barca.ufa.cas.cz',
type:'sftp',
port:22,
username:***,
password:***,
});
with this error:
Error: All configured authentication methods failed
at tryNextAuth (/home/jakub/Scripts/pvmaster/node_modules/ssh2/lib/client.js:376:17)
at SSH2Stream.onUSERAUTH_FAILURE (/home/jakub/Scripts/pvmaster/node_modules/ssh2/lib/client.js:587:5)
at emitTwo (events.js:87:13)
at SSH2Stream.emit (events.js:172:7)
at parsePacket (/home/jakub/Scripts/pvmaster/node_modules/ssh2-streams/lib/ssh.js:3923:10)
at SSH2Stream._transform (/home/jakub/Scripts/pvmaster/node_modules/ssh2-streams/lib/ssh.js:667:13)
at SSH2Stream.Transform._read (_stream_transform.js:167:10)
at SSH2Stream._read (/home/jakub/Scripts/pvmaster/node_modules/ssh2-streams/lib/ssh.js:251:15)
at SSH2Stream.Transform._write (_stream_transform.js:155:12)
at doWrite (_stream_writable.js:292:12)
But I can connect to sftp server via winSCP with no problems.
Could you please give me some advice?
I have the following code:
`
var EasyFtp = require('easy-ftp')
var ftp = new EasyFtp()
var config = {
host:'',
port: 21,
username: '',
password: '********',
type: 'ftp'
}
ftp.on("open", function(client){
console.log('open')
})
ftp.connect(config)
ftp.close(); `
But why there is no 'open' string showing in console ?
Any suggestion for helping me ?
Thanks
Hello!
When do connect, ls, mkdir. The script does not do anything and gives no messages.
ftp.connect(config);
ftp.mkdir("/directory", function(err){});
ftp.pwd(function(err, path) {
console.log(err);
console.log(path);
});
ftp.ls("/", function(err, list) {
console.log(err);
console.log(list);
});
ftp.close();
Please could you help me?
I have downloaded the code from the git
`var config1 = {
"host": "XXX",
"port": 21,
"username": "XXX",
"password": "XXX",
"type":"ftp"
};;
var loop = require('easy-loop');
var EasyFTP = require('../main');
var ftp1 = new EasyFTP(config1); //13967.730ms , 148819.925ms
//var ftp1 = EasyFTP.Parallel(config1, 3); // 56392.136ms, 49064.603ms
ftp1.on("open", function(client){
console.log("event open");
console.time("time");
//ftp1.upload("C:/test/images", config1.path, function(err){
ftp1.download("/AAAAAA5EEDF4/VIDEO/2018_0522_095610_001.MP4", "D:/test.MP4", function(err){
console.log(arguments);
console.timeEnd("time");
end();
});
});
ftp1.on("upload", function(){
console.log("event upload", arguments);
});
ftp1.on("download", function(){
console.log("event download", arguments);
});
ftp1.on("error", function(err){
console.log("event error1", err);
end();
});
ftp1.on("close", function(){
console.log("event close1");
});
//ftp1.cd(config1.path, function(){
//});
function end(){
try{ftp1.close();}catch(e){}
}`
And I use node easy-ftp-test.js to run the example code.
But the download process is not successful.
I watch from the FTP server side, it keeps recevicing pwd command, and download is stuck.
What's wrong in the code ?
Thanks for reply.
Could you please add a "remotepath" config option?
So that after connection automatically a cd remotepath is done?
async function downloadAttachmentFromFtp(localPath, ftpPath) {
const isConnected = await new Promise((resolve) =>
checkFtp((isConnected) => {
if (!isConnected) {
console.log("Is not connected.");
}
resolve(isConnected);
})
);
if (isConnected) {
ftp.connect(config);
const isSuccess = await new Promise((resolve) => {
ftp.download(ftpPath, localPath, (err) => {
if (err) {
console.log("Failed to download file.");
resolve(false);
} else {
resolve(true);
}
});
});
ftp.close();
return isSuccess;
} else {
console.log("No connection to the server.");
return false;
}
}
I am attempting to connect to an SFTP server and it seems it requires Keyboard Based Authentication .
Below is my code:
var EasyFTP = require('easy-ftp');
var ftp = new EasyFTP();
var sleep = require('sleep-async')();
var newFile;
var config = {
host: 'host',
port: port,
username: 'un',
password: 'pw',
type: 'sftp',
tryKeyboard: true
};
ftp.connect(config);
ftp.on('keyboard-interactive', function(name, instructions, lang, prompts, finish) {
console.log('Connection :: keyboard-interactive');
finish(['my_password_on_remote_machine']);
})
Hello
When i use easy-ftp i have on error, just with the code below
var easyFtp = require('easy-ftp');
A part of error
Error: UNKNOWN: unknown error, mkdir 'd:\test\새 폴더\test'
at Error (native)
at Object.fs.mkdirSync (fs.js:794:18)
at Object.mkdirsSync (c:\Users\xxxxx\Documents\xxxxx\node_modules\easy-ftp\node_modules\fs-extra\lib\mkdirs\mkdirs-sync.js:29:9)
This seems to be linked to path.resolve()...? It's just an idea, i begin with Node JS (i have discovered last week).
First of all, thanks for the great module !!!!!
When I upload a file to an ftp server these Deprecations warnings come up. The module works but I think is a good idea to fix them.
(node:21133) DeprecationWarning: Ftp.rawcwd: Use Ftp.raw('cwd args') instead. (node:21133) DeprecationWarning: Ftp.rawfeat: Use Ftp.raw('feat args') instead. (node:21133) DeprecationWarning: Ftp.rawsyst: Use Ftp.raw('syst args') instead. (node:21133) DeprecationWarning: Ftp.rawuser: Use Ftp.raw('user args') instead. (node:21133) DeprecationWarning: Ftp.rawpass: Use Ftp.raw('pass args') instead. (node:21133) DeprecationWarning: Ftp.rawtype: Use Ftp.raw('type args') instead. (node:21133) DeprecationWarning: Ftp.rawstat: Use Ftp.raw('stat args') instead. (node:21133) DeprecationWarning: Ftp.rawpwd: Use Ftp.raw('pwd args') instead.
Hello there!
I upload several files via separate post requests via multiple form file. I use express-fileupload. When I send I file at a time at pause 1 sec. - no problem easy-ftp sends file to server. But when I send 2+ requests with little to no pause then no upload is done and app halts. So if I wait for ftp callback - then no problem, but when in pending state the ftp client halts everything. So if I want to send 100 files simultaneously then ftp halts.
What may be a problem here?
var EasyFtp = require('easy-ftp');
var ftp = new EasyFtp();
var config = {
host: '####',
port: 22,
username: '###',
password: '###',
type : 'ftp'
};
ftp.connect(config);
ftp.cd("/", function(err, path){
ftp.ls('/mnt', function(err, list) {
console.log(list);
})
});
Is there anyway that I can check if the ftp connected successfully?
I can use open event but there is no event if connection is un-successfully.
also how do you unsubscribe events
First, thanks for this extension, it is very useful.
I open the ftp-simple-temp.json so as to configure my own connections, I change the tab where is opened the json configuration file to another tab, then if I try back to the configuration file tab, VS Code gives the "file not found" error and closes the configuration file tab.
Operative System: Windows 10
Code version: 1.8.1
Firstly, thank you for this great repo, It has made my app very very easy to build :) .
I'm having a problem with uploading a directory, my code looks like:
FTP_CLIENT.upload(PATH_TO_SCREENSHOTS, "/", function(err){
if(err){
console.log(err);
}else{
console.log('Bulk Upload function called');
}
});
(FTP client is EasyFTP, and PATH_TO_SCREENSHOTS is the path to the local images I wish to upload).
I'm getting this error,
Error: read ECONNRESET
at _errnoException (util.js:1022:11)
at TCP.onread (net.js:628:25)
Any help would be appreciated, thank you
Following is my code
`var EasyFtp = require('easy-ftp')
var ftp = new EasyFtp()
var config = {
host:'XXX',
port: 21,
username: 'XXX',
password: 'XXX',
type: 'ftp'
}
ftp.connect(config);`
I only do connection.
But in my FTP server, it keep receiveing pwd command every 10 seconds.
As you can see in the following picture.
Is there any problem in my code ?
...dir.../node_modules/ftp-simple/ftp.js:191
let newPath = pathUtil.join(path, value.name);
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (/Users/raymond/stack/sites/squarell-webpack/node_modules/ftp-simple/main.js:2:11)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy: node build/deploy.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/raymond/.npm/_logs/2017-07-07T08_56_38_324Z-debug.log
iMac:squarell-webpack raymond$
sftp mode does not seems to work at all. No error shown. Other sftp lib can do it, so the connection parameter are fine.
Hello! I Need a Fuction which can rename server filename
// Array - String
var arr = ["/test.txt", "/abcd/test2.txt", "/directory"];
ftp.mv(arr, "/archived", function(err, newPath){});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.