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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:31:02+00:00 2026-06-08T14:31:02+00:00

I am in a strange problem right now. I’ve been trying to upload an

  • 0

I am in a strange problem right now.
I’ve been trying to upload an image from my android app to the server, however it works fine when i am using wifi connection but when i am on GPRS the application just keeps on processing for an infinite amount of time. Below is the code:

    try
    {
        Log.i(TAG,"publishFileToServer Called...");
        FileInputStream fileInputStream = new FileInputStream(new File(filePath) );
        URL url = new URL(urlServer);
        System.setProperty("http.keepAlive", "false");
        connection = (HttpURLConnection) url.openConnection();
        Log.i(TAG,"publishFileToServer Called... 1");
        // Allow Inputs & Outputs
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.setUseCaches(false);
        Log.i(TAG,"publishFileToServer Called... 2");
        // Enable POST method
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Connection", "Keep-Alive");
        connection.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);
        Log.i(TAG,"publishFileToServer Called...3");
        outputStream = new DataOutputStream( connection.getOutputStream() );
        outputStream.writeBytes(twoHyphens + boundary + lineEnd);
        outputStream.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"" + filePath +"\"" + lineEnd);
        outputStream.writeBytes(lineEnd);
        Log.i(TAG,"publishFileToServer Called...4");
        bytesAvailable = fileInputStream.available();
        bufferSize = Math.min(bytesAvailable, maxBufferSize);
        buffer = new byte[bufferSize];
        Log.i(TAG,"publishFileToServer Called...5");
        // Read file
        bytesRead = fileInputStream.read(buffer, 0, bufferSize);
        Log.i(TAG,"publishFileToServer Called...6");
        while (bytesRead > 0)
        {
            outputStream.write(buffer, 0, bufferSize);
            bytesAvailable = fileInputStream.available();
            bufferSize = Math.min(bytesAvailable, maxBufferSize);
            bytesRead = fileInputStream.read(buffer, 0, bufferSize);
        }
        Log.i(TAG,"publishFileToServer Called...7");
        outputStream.writeBytes(lineEnd);
        outputStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
        Log.i(TAG,"publishFileToServer Called...8");
        // Responses from the server (code and message)
        int serverResponseCode = connection.getResponseCode();
        Log.i(TAG,"publishFileToServer: ServerResponseCode = "+serverResponseCode);
        String serverResponseMessage = connection.getResponseMessage();
        Log.i(TAG,"publishFileToServer: ServerResponseMessage = "+serverResponseMessage);
        Log.i(TAG,"publishFileToServer Called...9");
        fileInputStream.close();
        outputStream.flush();
        outputStream.close();
        Log.i(TAG,"publishFileToServer Called...10");
    }
    catch (Exception ex)
    {
        Log.e(TAG,"publishFileToServer: "+ex.getMessage());
    }

It’s noticeable that i use this same code to upload a text file an it works fine even on GPRS, i’ve tried to narrow it down and my application goes into the problem right before the getResponse() method when I am uploading an image.

  • 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-08T14:31:03+00:00Added an answer on June 8, 2026 at 2:31 pm

    Apparently the problem went away after a re-install of the sdk.

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

Sidebar

Related Questions

I'm facing a strange problem right now... I'm trying to use Facebook API to
I've come across a rather strange problem. What I'm trying to do right now
I'm writing a contact page, but I have a strange problem. Right from the
I've got a strange problem. I've been using just javascript forever now, and I'm
Right now I'm facing some kind of strange problem with a Weblogic domain. When
I am having a strange problem right now with CakePHP. I haven't used the
I have an extremely strange Problem, while trying to develop for android on eclipse
I've been having a strange problem that I've never seen before. Now I have
Right now I'm getting this strange problem where when I use jQuery's animate() function
Strange problem occurs on the production platform (64 bit win 2008 server). It is

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.