Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

FTP Woes! -Solved

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic