• Post Reply Bookmark Topic Watch Topic
  • New Topic

Attach a file to HttpURLConnection  RSS feed

 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I've got an applet that talks to a webserver using an HttpURLConnection
I need to send a binary file to the server (an exe)
I've succeded in sending a text file as POST data but I believe sending a binary file is a bit more complex
Can anyone point me to some info or an example?

Thanx
Dave
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is. Binary data should be sent as a multi-part form so you don't have to encode every byte. Use the Jakarta Commons File Upload package so you don't have to reinvent the wheel.
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick reply Joe
If I'm not mistaken, the fileupload package if for use in handling the upload on the server side. My problem is handling things on the applet/client side. Am I missing something??
Unfortunately I gotta use ASP on the server side
(insert tearful smile here)

So I've got something like this




And want to attach a file
Prior to this if poped a JFileChooser dialog and let the user select the file

Dave
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoops. Your post was a little vague as to which end you were interested in. The client side as implemented by the Jakarta Project is HttpClient. Have a look at the multipart post method doc.
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Joe
You Da Man!!

Dave
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Joe
You Da Man!!

Dave
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!