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

  • Home
  • SEARCH
  • 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 7817957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:24:38+00:00 2026-06-02T06:24:38+00:00

I am trying to send data to a web server using a post, this

  • 0

I am trying to send data to a web server using a post, this is what I have so far:

private void entity(String id, String file)
                throws JSONException, UnsupportedEncodingException, FileNotFoundException {
             // Add your data
            File myFile = new File(
                    Environment.getExternalStorageDirectory(), file);
            InputStreamEntity reqEntity = new InputStreamEntity(
                    new FileInputStream(myFile), myFile.length());

            reqEntity.setContentType("text/csv");
            reqEntity.setChunked(true); // Send in multiple parts if needed

            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
            nameValuePairs.add(new BasicNameValuePair("project", id));

            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            httppost.setEntity(reqEntity);

            //httppost.setHeader("Content-Length", String.valueOf(myFile.length()));

        }

When I send the post request it comes back with content-length required, but isn’t that set here?

InputStreamEntity reqEntity = new InputStreamEntity(
                    new FileInputStream(myFile), myFile.length()); 

I don’t know if what I am doing is right or not, please help, thanks


Edit –

When I try to set the content-length myself using

httppost.setHeader("Content-Length", String.valueOf(myFile.length()));

it comes back with header already set.

Hence why it is commented out

  • 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-06-02T06:24:39+00:00Added an answer on June 2, 2026 at 6:24 am

    You may want to use MultipartEntity and add parts using addPart methods with StringBody and InputStreamBody (or) FileBody

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I'm currently trying to send an image file to a web server using
I'm trying to post some very simple data to a php file using jquery
I was trying to parse response data from web server. I am using Xcode
I'm trying to send urlencode() data to my web server. The data used for
I am trying to send data from PHP Client to Python Server. CLIENT <?php
I am trying to send data from an activity to service via intents. This
I'm trying to send data to the Controller from the View. I have a
I'm trying to send post data between pages with Post. Not a form -
i am trying to send multiple data using j query $.ajax method to my
I'm trying to use cURL to post data to the form on this URL:

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.