File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes problem on reading the content of a file which has been uploaded in a remote ftp server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem on reading the content of a file which has been uploaded in a remote ftp server " Watch "problem on reading the content of a file which has been uploaded in a remote ftp server " New topic
Author

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

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

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


The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

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.)


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 692

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

Joined: Oct 27, 2005
Posts: 19696
    
  20

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

Joined: Jul 03, 2011
Posts: 692

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

Joined: Oct 27, 2005
Posts: 19696
    
  20

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

Joined: Jul 03, 2011
Posts: 692

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem on reading the content of a file which has been uploaded in a remote ftp server