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 6819695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:20:13+00:00 2026-05-26T21:20:13+00:00

I’m looking for simple and clean solution for HTTP multipart post, which will send

  • 0

I’m looking for simple and clean solution for HTTP multipart post, which will send some Strings (form data) and several files with streaming support. (files needs to be streamed to avoid out of memory error)
I’d like to achieve this with the built-in “org.apache.httpclient” if possible.

I was able to create a clean solution with HttpURLConnection.
Despite all my efforts with this solution strings were sent with 8859-x encoding instead of UTF-8.

EDIT: My code is available at MultiPart with HttpURLConnection source

I created an output stream with this code:

HttpURLConnection connection = setupConnection();
dataOutputStream = new DataOutputStream(connection.getOutputStream());

After this I just wrote the data with dataOutputStream.writeBytes

If i could get an outputstream from httpclient it would be great, however it seems it works a different way.

Any help is appreciated.
Thanks

  • 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-26T21:20:14+00:00Added an answer on May 26, 2026 at 9:20 pm

    I’ve just created a simple solution for this: android_multipart_entity.

    It’s free (including for commercial usage), however if this is possible please keep references to me inside of my classes.

    It’s designed to be used with the built in Android HttpClient. Sample usage code:

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://www.yourhost.com");
    MultipartEntity entity = new MultipartEntity();
    entity.addPart(new StringPart("name", "yourname"));
    File imageFile = // .. get your image file
    entity.addPart(new FilePart("picture", imageFile, null, "image/jpeg"));
    httppost.setEntity(entity);
    HttpResponse httpResponse = httpclient.execute(httppost);
    

    EDIT:

    I reviewed your MultiPart with HttpURLConnection code. You get UTF-8 issue because of DataOutputStream usage. API says for that class:

    Wraps an existing OutputStream and writes big-endian typed data to it. Typically, this stream can be read in by DataInputStream.

    This class just does not suit your needs. In order to read the data you would have to have its direct opposite – DataInputStream on the other end.

    So my advice would be to use plain OutputStream. And write bytes to it. Smth like this:

    outputStream.write(partSeparator.getBytes());
    outputStream.write(("Content-Disposition: form-data; name=\"" + parameter.getKey() + "\"" + lineEnd).getBytes());
    outputStream.write(("Content-Type: text/plain; charset=UTF-8" + lineEnd).getBytes());
    outputStream.write(("Content-Transfer-Encoding: 8bit" + lineEnd).getBytes());
    outputStream.write(lineEnd.getBytes());
    outputStream.write(parameter.getValue().getBytes("UTF-8")); // <= this is it!
    outputStream.write(lineEnd.getBytes());
    outputStream.write(partSeparator.getBytes());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a function that will clean a strings' special characters. I do NOT
I have just tried to save a simple *.rtf file with some websites and
I have a text area in my form which accepts all possible characters from
I have some data like this: 1 2 3 4 5 9 2 6
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.