• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Attach a file to HttpURLConnection

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Joe
You Da Man!!

Dave
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Joe
You Da Man!!

Dave
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic