Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7678891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:45:01+00:00 2026-05-31T17:45:01+00:00

My server receives multipart form data from a mobile app. The result of printing

  • 0

My server receives multipart form data from a mobile app. The result of printing out the request using request.content.toString(UTF_8) is shown below. The image is sent by the mobile as a base64-encoded string. How do I save the image data to file?

--*****org.apache.cordova.formBoundary
Content-Disposition: form-data; name="value1"

Furniture
--*****org.apache.cordova.formBoundary
Content-Disposition: form-data; name="value2"

Chair
--*****org.apache.cordova.formBoundary
Content-Disposition: form-data; name="file"; filename="image.jpg"
Content-Type: image/jpeg

����JFIF��XExifMM*�i...rest of image goes here...
--*****org.apache.cordova.formBoundary--
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:45:03+00:00Added an answer on May 31, 2026 at 5:45 pm

    I am yet to parse the multipart form data, but saving the image turned out to be easy (once you know how). To test, I’m uploading only the image during testing using:

    curl -T "image.jpg" http://127.0.0.1:8080/imageupload
    

    I’m using Finagle, which depends on the netty libraries, so the request.content() returns a object of type org.jboss.netty.buffer.ChannelBuffer, for which you extract the image data as follows:

    To save the file from the request content to file:

      val raf = new java.io.RandomAccessFile("image.jpg", "rw");
      val buf = request.getContent();
      val fChannel = raf.getChannel();
    
      fChannel.write( buf.toByteBuffer() );
      raf.close();
      fChannel.close();
    

    To pass the request content on to a web service expecting base64binary:

      import org.jboss.netty.util.CharsetUtil._
      import org.jboss.netty.handler.codec.base64.Base64
    
      val base64binaryImage = (Base64.encode(request.getContent())).toString(UTF_8)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using FileReader.readAsBinaryString to upload a file using a multipart/form-data POST request to a
I'm testing with firefox at the moment. The server receives an HTTP request from
I am using pictureBox to show images which are received from server but my
I have a Windows/Apache2/PHP app that receives file using chunked encoding. The reason is
When a server receives a WSAECONNABORTED from a device (coming in from a send()
I have this form to upload an xml file to server, I am using
When I create a new websocket using chrome new WebSocket('ws://gert:passwd@127.0.0.1:8001/dbname') The nodejs server receives
Say my web server receives two simultaneous requests. It will handle each request in
I have the following script for sending mails using python import smtplib from email.mime.multipart
I have a SWF file that connects to a remote flash server and receives

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.