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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:46:28+00:00 2026-05-25T10:46:28+00:00

When I try to upload images or larger files from my android app it

  • 0

When I try to upload images or larger files from my android app it crashes with an OutOfMemoryException. Im wondering if there are any alternate ways of doing this.

Ive had the application crash in two different spots:

Base64.encodeToString(bytes, Base64.DEFAULT);

And here where the base64 string is one of the values in the nameValuPairs collection.

HttpClient client = new DefaultHttpClient();
HttpPost httppost = new HttpPost(uo.WebServiceURL);
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(nameValuePairs); // On this line
httppost.setEntity(entity);
HttpResponse response = client.execute(httppost);

Any ideas?

  • 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-25T10:46:29+00:00Added an answer on May 25, 2026 at 10:46 am

    If you do it like that, the whole POST must be buffered in memory.
    This is because it needs to send the Content-Length header first.

    Instead, I think you want to use the Apache HTTP libraries, including
    http://developer.android.com/reference/org/apache/http/entity/FileEntity.html
    . That will let it figure out the length before reading the file. You
    can use this answer as a starting point. But the second parameter to
    the FileEntity constructor should be a mime type (like image/png,
    text/html, etc.).

    Posting a large file in Android

    Check This also ………

    As Schnapple says your question seems very broad and is confusing to read and understand.

    Here is some general code to send a HTTP POST and get a response from a server though that may be helpful.

    public String postPage(String url, File data, boolean returnAddr) {
    
        ret = null;
    
        httpClient.getParams().setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2109);
    
        httpPost = new HttpPost(url);
        response = null;
    
        FileEntity tmp = null;       
    
        tmp = new FileEntity(data,"UTF-8");
    
        httpPost.setEntity(tmp);
    
        try {
            response = httpClient.execute(httpPost,localContext);
        } catch (ClientProtocolException e) {
            System.out.println("HTTPHelp : ClientProtocolException : "+e);
        } catch (IOException e) {
            System.out.println("HTTPHelp : IOException : "+e);
        } 
                ret = response.getStatusLine().toString();
    
                return ret;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when i try to upload two files in the form, it doesn't happen!!! here
My app is crashing when I try to post images in an HTTP request.
I am creating an app which will be used to upload images to a
I want to upload images from the client to the server. I already managed
I want to create a django app that can upload and display images. However
We are using Magento ver1.6.1 to develop a website. When try upload images for
When I go to myserver index and upload and image from there using the
I am new to git and when I try to upload my newly created
I try this command to upload a file (standard.xml) into table book the file
I'm using SWFUpload and Paperclip on Rails 2.3.5 to upload images and videos. How

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.