Reputation: 1394
I am using the apache commons FTP library and attempting to view a file on a USB stick that is running VXWorks. Every time I try to view any file from that system it returns a 0 file size. This works fine when the server is a Windows machine. The code I'm using is:
public synchronized long getRemoteSize(String finalPath)
{
// Send file and if sent file doesn't match the source file, resend
try
{
FTPFile destinationFile = jh.getFtpClient().mlistFile(finalPath);
if (destinationFile != null)
{
return destinationFile.getSize();
}
else
{
return 0;
}
}
catch (IOException e)
{
return -1;
}
}
I have also tried to send a straight SIZE command and it was not recognized. Anyone have any other options or any explanation as to why it always comes back at 0 size?
Upvotes: 0
Views: 349
Reputation: 2050
It sounds like your VXWorks FTP server doesn't support the MLST
command which is what mlistFile()
uses under the hood. The MLST
command was added with RFC 3659. In order to use the command the server would need to implement that RFC.
Your best bet is to use the LIST
command (e.g. listFiles(pathName)
). This should be the most compatible function of the bunch. This function returns an array instead of a single file, so you'll need to check the return length == 1, but otherwise should be a more-or-less drop in replacement.
Upvotes: 1