File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Security and the fly likes File upload and download use SSL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "File upload and download use SSL?" Watch "File upload and download use SSL?" New topic
Author

File upload and download use SSL?

Calson LI
Ranch Hand

Joined: Nov 18, 2005
Posts: 42
Hi all,

We have a web application using SSL. But this web application provides uploading file from client to web server and downloading file from web server to client. Will file upload and file download use SSL?

Thanks for your assistance in advance.

Calson
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41598
    
  55
It should work just fine if you use an "https:" URL instead of an "http:" URL. Did you encounter any problems?


Ping & DNS - my free Android networking tools app
Calson LI
Ranch Hand

Joined: Nov 18, 2005
Posts: 42
Thanks for your response, ULF.

Actually, there are 2 ways of uploading file to web server in a web application using 'https'.

Method 1. In doGet() of doPost() method, write code like the following
public void doGet(... req, ... res) {
res.setContentType("application/jar");
File f = new File("test.jar");
byte [] byteArray = new byte[(int) f.length()];
FileInputStream is = new FileInputStream(f);
is.read(byteArray);
OutputStream os = res.getOutputStream();
os.write(byteArray);
os.flush();
}

Method 2. Use 3rd party jar to upload file to web server.

To my understanding Method 1 should use SSL channel, i.e. https. Am I right?

But for Method 2, if we use https, will method 2 use this secure channel to send data from client to web server?

Thank you,
Calson
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41598
    
  55
I'm a bit confused. Both methods seem to do the same, only that method 1 is coded by you, while method 2 is coded by the developers of a 3rd party library. Of course, method 1 looks like it facilitates the download of a file, not an upload, so no URL would need to be specified.
Calson LI
Ranch Hand

Joined: Nov 18, 2005
Posts: 42
Hi Ulf,

Thanks a lot for your reply. Yes, you are right, method 1 is downloading. I am more worrying about method 2.

Regards,
Calson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File upload and download use SSL?