wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes FTP Woes! -Solved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "FTP Woes! -Solved" Watch "FTP Woes! -Solved" New topic
Author

FTP Woes! -Solved

Jaz Chana
Ranch Hand

Joined: Feb 19, 2008
Posts: 34
Hi Guys,

So I'm using the apache commons classes and have created the following ftp method;



I ran the piece of code on a windows machine and no problems. I then ran the code on my mac and for some reason it doesn't work, to specify; the client logs in, it creates the testDir, but it doesn't upload any files. To make things worse theres little indication as to why it doesn't work. There is no stack trace, no error message, I've checked the permissions of the directory and its contents and they all seem to be readable and writable by all. I even created a FileOutputStream to write the contents of the FileInputStream on to the desktop so that I can verify that its actually working. And the files are written correctly, without any corruption. The only thing that indicates anything is wrong is the return code of the method getReplyCode(). After every attempt to upload I get the 500 response, so I looked this up and it means "Syntax error, command unrecognized. This may include errors such as command line too long". That's not very helpful unfortunately.


I'm at a loss here, because the same piece of code works fine on a windows machine. Is there anything that I could be missing?

Cheers
Jaz Chana
Ranch Hand

Joined: Feb 19, 2008
Posts: 34
Okay so I figured out what the problem was. Basically I needed to set the following on my instance of ftp client;



because I'm uploading images not text files. And the following;



I'm not 100% but i believe its because I'm behind a firewall. Also I found adding this piece of code really helps the debugging process;



It basically outputs to the console everything that the server replies with.
 
 
subject: FTP Woes! -Solved
 
Similar Threads
How to zip files and folders in a directory into 1 zip file?
How to upload file to ftp in java
FTP very slow
file size issue when copying zip with commons net api
Commons-net FTP and AIX 5.3 FTP Server