> Hi All,
>
> Following ocde is used to download file from unix server, when i try on
> window server, the downloading is fine. However when i download from
> unix server in binary mode. The file is empty. Is there anything i
> should take note of when trying to download file from unix
...
> response.setHeader("Content-Disposition","attachment;
> filename=\"" + fileName);
System.getProperty("path.separator") ?
Andrew T.
Guan - 08 Nov 2006 16:02 GMT
y need this line "System.getProperty("path.separator") ?"
> > Hi All,
> >
[quoted text clipped - 9 lines]
>
> Andrew T.
Andrew Thompson - 08 Nov 2006 16:45 GMT
Please refrain from top-posting.
> y...
Is something wrong with the 'w' and 'h' keys
on your keyboard? Please fix it.
>...need this line "System.getProperty("path.separator") ?"
OK, given I am not psychic, I will take you back to this line..
> > > response.setHeader("Content-Disposition","attachment;
> > > filename=\"" + fileName);
..and ask.
1) What is the content of the String referenced by fileName
at this point in the code?
2) What did your perusal of the JavaDocs, and the output
of the path.separator string, suggest it means to you?
Andrew T.
Guan - 11 Nov 2006 12:59 GMT
Hi All,
Thanks for your help. I had solve the problem :)
Guan - 11 Nov 2006 12:59 GMT
Hi All,
Thanks for your help. I had solve the problem :)
Guan - 11 Nov 2006 13:00 GMT
Hi All,
Thanks for your help. I had solve the problem :)
Guan - 11 Nov 2006 13:01 GMT
Hi All,
Thanks for your help. My problem is solved. :)
Luc The Perverse - 11 Nov 2006 19:48 GMT
> Hi All,
>
> Thanks for your help. My problem is solved. :)
Now to address the issue of you posting your reply 4 times without quoting
--
LTP
:)
> Following ocde is used to download file from unix server, when i try on
> window server, the downloading is fine. However when i download from
> unix server in binary mode. The file is empty. Is there anything i
> should take note of when trying to download file from unix
What do you mean binary mode? Non text/ content type?
> response.setHeader("Content-Disposition","attachment;
> filename=\"" + fileName);
My knee-jerk reaction is that if you don't know for sure the source of
fileName, could have something malicious in it (new lines, NUL
characters, double quotes, that sort of stuff). My second reaction is
that you only have a single double quote.
> inputStream = new BufferedInputStream((fileName));
I take it this isn't your real code. It's difficult to diagnose problems
without seeing the actual code.
Tom Hawtin
Guan - 08 Nov 2006 16:11 GMT
Hi,
Thanks for all of you for your time for reading my posting and giving
comments
I hope the following code is sufficient for you. THis the not the full
program it is the downloading part as the whole program is quite long
I am using netcomponents FTP class to retrive file from FTP server, I
tested this code to retrive file From FTP running on windows platform
and it seem ok.. Howerver when i tried to retrieve file from ftp server
on unix plaform. The file i download is empty content
==========================================================
ftp = new FTPClient();
ftp.connect(FTP_SERVER);
int reply = ftp.getReplyCode();
if
(!com.oroinc.net.ftp.FTPReply.isPositiveCompletion(reply))
throw new java.io.IOException("Could not connect to ftp
server " +
FTP_SERVER);
ftp.login(ftpUserId, ftpPassword);
ftp.setFileType(com.oroinc.net.ftp.FTP.BINARY_FILE_TYPE);
ftp.changeWorkingDirectory(ftp.printWorkingDirectory());
try {
// Retrieve the file
response.setHeader("Content-Type",
"application/x-download");
response.setHeader("Content-Disposition","attachment;
filename=\"" + fileName);
outputStream = response.getOutputStream();
//outputLocalBuf = new
BufferedOutputStream(outputLocal);
if (ftp.retrieveFileStream(fileName)==null)
throw new java.io.IOException(
"Get file from remote ftp host failed");
else{
inputStream = new BufferedInputStream(
(ftp.retrieveFileStream(fileName)));
int data;
while((data = inputStream.read()) != -1) {
outputStream.write(data);
}
}
} finally {
if (inputStream != null) inputStream.close();
if (outputStream != null) outputStream.close();
Thanks
> > Following ocde is used to download file from unix server, when i try on
> > window server, the downloading is fine. However when i download from
[quoted text clipped - 17 lines]
>
> Tom Hawtin