Comments (14)
What if you instead just change the line
stream.setEncoding('utf8');
to
stream.setEncoding('binary');
?
from node-ftp.
no, that don't work. output : âÊÔ.md
when file name is 测试.md
nodejs is not support gbk now, so we need modules like iconv / iconv-lite
from node-ftp.
I have the same issue
from node-ftp.
stream.setEncoding('binary');
^
TypeError: Cannot call method 'setEncoding' of undefined
at FTP._pasvGetLines (C:\CroNode\node_modules\ftp\ftp.js:508:12)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
[Finished in 0.4s with exit code 1]
from node-ftp.
changing ftp.js encoding to utf8 the error is the same.
I was testing conn.get '1.txt'
from node-ftp.
@ramstein74 With the original code from master, can you set debug: console.log
in the constructor options and post the output somewhere? I'm very interested in finding out what's causing this....
from node-ftp.
i solved this problem.
I did not have auth to download a file from ftp server.
Next error
i saw with node inspector
The console error is ftp_test.js:35
Server error:425 Unable to open the data connection
in node monitor (web) tracing stops at this file
Timers.JS
line 109
debug(msecs + ' list empty');
assert(L.isEmpty(list));
list.close();
delete lists[msecs];
};here exists!!!!!!!!!!!!!
}
My app is in coffee so i converted it to javascript (code below)
(function() {
var FTPClient, conn;
FTPClient = require("ftp");
conn = new FTPClient();
conn.on("connect", function() {
return conn.auth(function(e) {
if (e) {
throw e;
}
conn.cwd('\ftproot\memcard', function() {
return conn.pwd(function(e, dir) {
if (e) {
throw e;
}
return console.log(dir);
});
});
conn.get('1.txt', function(e, st) {
if (e) {
throw e;
}
st.on('success', function() {
return console.log("file received ok");
});
return st.on('error', function() {
return console.log("erro in file");
});
});
return conn.list(function(e, entries) {
var i, len;
if (e) {
throw e; This is line 35!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ( if i remove the get file code, the listing goes ok)
}
console.log("");
i = 0;
len = entries.length;
console.log(len);
while (i < len) {
if (typeof entries[i] !== "string") {
if (entries[i].type === "l") {
entries[i].type = "LINK";
} else if (entries[i].type === "-") {
entries[i].type = "FILE";
} else {
if (entries[i].type === "d") {
entries[i].type = "DIR";
}
}
console.log(" " + entries[i].type + " " + entries[i].size + " " + entries[i].date + " " + entries[i].name);
}
++i;
}
console.log("");
return conn.end();
});
});
});
conn.connect();
}).call(this);
from node-ftp.
Please try with the master branch now if you can and let me know how it goes. All file names should be 'binary' strings.
from node-ftp.
i can get the file lists from the ftp, and with iconv.decode(list.name, 'gbk') I can get the correct Chinese, but the problem is how can I get the specified file lists of a folder in Chinese, like ‘/测试’
i can't the file lists with
ftpClient.list( ‘/测试’, (e, list1) => { if (e) throw e; console.log(list1); });
but it;s ok with
ftpClient.list( ‘/test’, (e, list1) => { if (e) throw e; console.log(list1); });
from node-ftp.
@lizhipower any advance on this? How did you solve this? I'm facing the same issue here.
from node-ftp.
from node-ftp.
@mscdex you should use Buffer with filepath, or add a encode option with method such as list, cwd etc.
FTP.prototype.cwd = function (path, cb, promote) {
let cmddata = 'CWD ';
if (Buffer.isBuffer(path)) cmddata = Buffer.concat([Buffer.from(cmddata), path]);
else cmddata += path;
this._send(cmddata, function (err, text, code) {
if (err)
return cb(err);
var m = RE_WD.exec(text);
cb(undefined, m ? m[1] : undefined);
}, promote);
};
FTP.prototype._send = function (cmd, cb, promote) {
clearTimeout(this._keepalive);
if (cmd !== undefined) {
if (promote)
this._queue.unshift({
cmd: cmd,
cb: cb
});
else
this._queue.push({
cmd: cmd,
cb: cb
});
}
var queueLen = this._queue.length;
if (!this._curReq && queueLen && this._socket && this._socket.readable) {
this._curReq = this._queue.shift();
if (this._curReq.cmd === 'ABOR' && this._pasvSocket)
this._pasvSocket.aborting = true;
this._debug && this._debug('[connection] > ' + inspect(this._curReq.cmd));
let cmddata = this._curReq.cmd;
if (Buffer.isBuffer(cmddata)) cmddata = Buffer.concat([cmddata, Buffer.from('\r\n')]);
else cmddata += '\r\n';
this._socket.write(cmddata);
} else if (!this._curReq && !queueLen && this._ending)
this._reset();
};
from node-ftp.
i can get the file lists from the ftp, and with iconv.decode(list.name, 'gbk') I can get the correct Chinese, but the problem is how can I get the specified file lists of a folder in Chinese, like ‘/测试’
i can't the file lists with
ftpClient.list( ‘/测试’, (e, list1) => { if (e) throw e; console.log(list1); });
but it;s ok with
ftpClient.list( ‘/test’, (e, list1) => { if (e) throw e; console.log(list1); });
how to resolve it?
from node-ftp.
i can get the file lists from the ftp, and with iconv.decode(list.name, 'gbk') I can get the correct Chinese, but the problem is how can I get the specified file lists of a folder in Chinese, like ‘/测试’
i can't the file lists with
ftpClient.list( ‘/测试’, (e, list1) => { if (e) throw e; console.log(list1); });
but it;s ok with
ftpClient.list( ‘/test’, (e, list1) => { if (e) throw e; console.log(list1); });
I resolve it , You need convert 'cmd' to 'GBK'.
var iconv = require("../../iconv-lite");
FTP.prototype._send = function(cmd, cb, promote) {
clearTimeout(this._keepalive);
if (cmd !== undefined) {
if (promote)
this._queue.unshift({ cmd: cmd, cb: cb });
else
this._queue.push({ cmd: cmd, cb: cb });
}
var queueLen = this._queue.length;
if (!this._curReq && queueLen && this._socket && this._socket.readable) {
this._curReq = this._queue.shift();
if (this._curReq.cmd === 'ABOR' && this._pasvSocket)
this._pasvSocket.aborting = true;
this._debug&&this._debug('[connection] > ' + inspect(this._curReq.cmd));
let cmd = this._curReq.cmd + '\r\n';
let buf = iconv.encode(cmd, 'gbk');
this._socket.write(buf);
} else if (!this._curReq && !queueLen && this._ending)
this._reset();
};
from node-ftp.
Related Issues (20)
- File not fully uploaded HOT 2
- routines:ssl_choose_client_version:unsupported
- Could not get "pipe" of undefined.
- Ready And Greeting Event not triggered while connecting
- Error: You aren't logged in HOT 3
- is there a way to get an index.html? HOT 1
- encode strings to latin-1
- Error: connect ECONNREFUSED 127.0.0.1:21 HOT 2
- connect with different interface (like eth2)
- rmdir (recursive) fails with unicode chacaters HOT 1
- New maintainers needed for ftp in node
- transfer get stuck
- Catch connection error is not possible HOT 1
- ECONNRESET Error using ftp after few mintues HOT 1
- [Doubt] list of files/folders of FTP SERVER
- Corrupted zip when I download them with the package
- Connect directly into specified remote directory
- Error occurred when running in Electron.
- Add Promise versions of methods
- Issue with Vercel, works perfectly on local
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-ftp.