This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FTP transaction using a servlet

 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a program that uploads files to a FTP server and then downloads it if necessary later on. The program is working successfully but there is a problem when i download the file. The file is an excel file and when i try to open it the following message is displayed... "The file cannot be accessed. The file may be read only or the server where this file is located is not responding.

Well i have already downloaded the file so the latter part of that sentence does not bear any relevance. I tried to download the file using cute FTP and the download was successfull but yet again i got the same error. So is this something to do with file permissions ? Do i have to change the permissions for that file in the FTP server and then save it ? What is going wrong here ?

I opened the file in notepad and all the data is still there but it just wont let me open the file. HELP !!!


Update: I tried to upload and download the file using cute FTP and it worked. But if i upload with the program and then download it screws up. I am using the FTPClient class and the storeFile and retrieveFile functions in that class. any ideas ?
[ July 03, 2006: Message edited by: John Meyers ]
 
Santhosh Kumar
Ranch Hand
Posts: 242
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have not mentioned which OSs you are using. If you are transferring the files between windows and unix like systems, you need to take care to set the mode correctly for binary file (excel file is binary file). By default mode is ascii so you might have to set to binary.

When you use CuteFTP to upload the file, it would upload the excel file in binary mode.

This is the only hint I'm getting eventhough this issue does not strike anything to the error you getting. However you can give this a try.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried specifically setting the file type to binary but no luck. Its so wierd ! All the data has been downloaded and i can see whatever words i have saved in the xls when i open it with notepad. But for some reason it just wont open up !!! Any other ideas people ? Keep em coming. Thanks
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey it worked !!! guess what i did explicitly mention that the file type was supposed to be binary but... err... i umm forgot to recompile the code after that

Damn ! forgot to check the transfer type in the first place.

Thanks Santhosh
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic