Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File upload and download use SSL?

 
Calson LI
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should work just fine if you use an "https:" URL instead of an "http:" URL. Did you encounter any problems?
 
Calson LI
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic