• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem on reading the content of a file which has been uploaded in a remote ftp server

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi , i m trying to upload any type files to an ftp server through my code
it actually uploads the file but when ever i try to open that file in the server pc only .txt files open up properly and for all the other type of files it says file is either corrupted or damage ...i had also set the file structure to binary file structure
but still this is not happening ...how to correct this can any one tell me ?
i m using apache commons net
 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the code that does the connecting and uploading? (You should of course change the host, user name and password before posting. We don't need that information.)
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Can you show us the code that does the connecting and uploading? (You should of course change the host, user name and password before posting. We don't need that information.)


 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can only see two things wrong, and neither of them has anything to do with the upload.

First of all, if you can't create the InputStream you catch an exception but still continue with code that will use the InputStream. That won't work.

Secondly, you're performing a heavy operation (the file upload) on the Event Dispatcher Thread. You should really use a SwingWorker for that.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:I can only see two things wrong, and neither of them has anything to do with the upload.

First of all, if you can't create the InputStream you catch an exception but still continue with code that will use the InputStream. That won't work.

Secondly, you're performing a heavy operation (the file upload) on the Event Dispatcher Thread. You should really use a SwingWorker for that.


but this too does not solve my problem now what next ? soory but what ever i have shown you in my earlier code in the same way downloading code is written but it works fine, all files open up nicely including , mp3 , docx , rar , mp4 , ppt , xls , vlc , .txt and so on
but this uploading code only works with .txt but all the other files type like mp3 , vlc show me that some kind of error , or show file is damaged for pics like jpeg , png , docx .. and all



rob i guess this is a bug in apache commons net because this was the bug in apache 3.0 they are claiming that this have been resolved but i guess there are lot of problem similar to this on net forums
please can you try a simple java program for uploading a file to ftp server and please use files like flv , docx , or images
waiting for your reply
if you try it will be help full to both of us thanks for helping
 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If Apache Commons Net is still broken you can switch to a different FTP library. I can recommend JvFTP. There's a tutorial available on their website.
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:If Apache Commons Net is still broken you can switch to a different FTP library. I can recommend JvFTP. There's a tutorial available on their website.

i had changed the library
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic