Open ghost opened 7 years ago
no people?
same issue here. strangely it only happens on one ftp server and not on another. i suspect it has something to do with different FTP Server systems. most of them return an object, but some do in fact return a string.
Just a suggestion. I think you should offer your ftp server related information
Your server no response owner or group permission name and the parser can't process it. Which do you use server and operating system?
same issue...It works great at work on windows but not on my mac. Can't get response of list method
Still encountering the same issue. Tried on Ubuntu and MacOS.
If anyone stumbles upon this issue, this is how I resolved it. However, I am not sure that this solution will work for every FTP server.
Code is in Typescript:
enum ListingType {
Directory = "d",
File = "-",
Symlink = "l",
}
enum SpecialListingType {
Directory = "*DIR",
File = "*STMF",
Symlink = "l",
}
const getFtpListingElement = (entry: string | ListingElement): ListingElement => {
if (typeof entry !== "string") {
return entry;
}
// `entry` is something like "OWNER 1234 12/12/19 18:19:20 *SFTIM Path/To/The/FileOrFolder/Location"
const [
owner,
size,
lastDateModified,
lastTimeModified,
type, // Afaik can be of 3 types - *DIR (dir), *SFTIM (file) or something else that I haven't encountered but which would stand for Symlink
name,
] = entry
.split(" ")
.map((part) => part.trim())
.filter(Boolean)
;
return {
owner,
group: owner,
size,
date: new Date(`${lastDateModified} ${lastTimeModified}`),
name,
type: getListingType(type as SpecialListingType), // Each type above corresponds to a type character mentioned in the docs - d (dir), - (file), l (symlink)
};
};
const listings = (await ftp.list("/my/path")).map(getFtpListingElement);
The problem with this is that there is no data about permissions. At least not in my case. Let me know if this works for you.
I find the problem only when I cancel the execute permission of the group. But I don't know why it can cause the problem
let c = Clinet();
c.on('ready', function() { c.list(path, function(err, list) { if (err) throw err; console.log(list); }); });
[ '-rw-r--r-- 1 oinstall 65536 Jul 25 15:01 csxl20170724.dmp', 'drwxr-xr-x 2 oinstall 4096 Jul 25 14:33 log' ]
why the list() return an array of strings, not object?