Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to upload an image as a http request using MIME  RSS feed

 
arsh Kanu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
 
Rob Spoor
Sheriff
Posts: 21047
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!