• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to upload an image as a http request using MIME

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am trying to upload an image into a website using Valence API as shown in this link, http://docs.valence.desire2learn.com/basic/fileupload.html
I have set the headers like Content-Type and Content-Length, but i am unable to understand the rest of the body as i am new to MIME.

I need to create a MIME body using java like this :

--xxBOUNDARYxx
Content-Disposition: form-data; name="file"; filename="img.jpg"
Content-Type: image/jpeg

{image data here}
--xxBOUNDARYxx--
how do i start and where should i start/
does the "{image data here}" above mean image converted into bytes?

Any help is appreciated.
-Thanks
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to MIME encode it, which is basically Base64 but with lines of 76 characters (including \r\n line break). See http://en.wikipedia.org/wiki/Base64 for more information.
 
arsh Kanu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:You need to MIME encode it, which is basically Base64 but with lines of 76 characters (including \r\n line break). See http://en.wikipedia.org/wiki/Base64 for more information.



Hi Rob,
I have converted the image into Base64 using the following code:

The above code gives me a big chunk of alpha-numeric representation of the image.
Is this correct Or should i have to do it only by MIME?

-Thanks
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic