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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:46:08+00:00 2026-05-29T05:46:08+00:00

STACkers… I have a webserver with shared folder… It’s address is: http://192.168.1.1:9999/folder/0 I have

  • 0

STACkers…
I have a webserver with shared folder… It’s address is:

    "http://192.168.1.1:9999/folder/0" 

I have googled a lot of information about downloading files and need help…

  1. Downloading is success… How can I do uploading files to my droid??? (permissions on server are enabled)…

    case R.id.download:
        try {
             java.net.URL u = new java.net.URL("http://192.168.1.1:9999/file/2/01.mp3");
                HttpURLConnection c = (HttpURLConnection) u.openConnection();
    
                c.setRequestMethod("GET");
                c.setDoOutput(true);
                c.connect();
                FileOutputStream f = new FileOutputStream(new File("/sdcard/in", "01.mp3"));
    
    
                InputStream in = c.getInputStream();
    
                byte[] buffer = new byte[1024];
                int len1 = 0;
                while ( (len1 = in.read(buffer)) > 0 ) 
                {
                     f.write(buffer,0, len1);
                }
                f.close();
        }
        catch (Exception e) {
            System.out.println("Nay, did not work");
            textView.setText(e.getMessage());
        }
        break;  
    
  2. Network connection fail frequently especially for mobile clients. For example if you switch from Wifi to 3G then an existing network connection will break and you need to retry the request. The Apache HttpClient has an default DefaultHttpRequestRetryHandler object registered which will per default 3 times retry a failed connection. The problem is that switching from one network to another make take a little while and DefaultHttpRequestRetryHandler will retry immediately. How implement it to MY Down/UpLoading???
  • 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-29T05:46:09+00:00Added an answer on May 29, 2026 at 5:46 am
    Please make sure you have the required Web Services for Posting.
    Just pass the file and url of server and the following should run. 
    
       try{
                        int maxBufferSize=1024*1024;
                        File file = new File(YourPathToFile); 
                        String fileName = file.getName();
    
                            URL url = new URL(YourUrlServer);
                           connection = (HttpURLConnection) url.openConnection();
                       // Allow Inputs & Outputs
                        connection.setDoInput(true);
                        connection.setDoOutput(true);
                        connection.setUseCaches(false);
                        // Enable POST method
                        connection.setRequestMethod("GET");
                        connection.setRequestProperty("Connection", "Keep-Alive");
                        connection.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);
                        connection.setChunkedStreamingMode(maxBufferSize);
                        outputStream = new DataOutputStream( connection.getOutputStream() );
    
                        fileInputStream = new FileInputStream(file);
    
    
                        outputStream.writeBytes(twoHyphens + boundary + lineEnd);
                        outputStream.writeBytes("Content-Disposition: form-data; name=\"strAuthKey\"" + lineEnd);
                        outputStream.writeBytes(lineEnd);
                        outputStream.writeBytes(SoapRequestProcessor.authKey());//authentication key
                        outputStream.writeBytes(lineEnd);
    
                        outputStream.writeBytes(twoHyphens + boundary + lineEnd);
                        outputStream.writeBytes("Content-Disposition: form-data; name=\"mediaName\"" + lineEnd);
                        outputStream.writeBytes(lineEnd);
                        outputStream.writeBytes(fileName); //file.lastModified()+"_"+
                        outputStream.writeBytes(lineEnd);
    
    
                        outputStream.writeBytes(twoHyphens + boundary + lineEnd);
                        outputStream.writeBytes("Content-Disposition: form-data; name=\"uploadedfile\";filename=\"IMAGEFILE\"" + lineEnd);
                        outputStream.writeBytes(lineEnd);
                        bytesAvailable = fileInputStream.available();
                        bufferSize = Math.min(bytesAvailable, maxBufferSize);
                        buffer = new byte[bufferSize];
                        bytesRead = fileInputStream.read(buffer, 0, bufferSize);
                        while (bytesRead > 0)
                        {
                        outputStream.write(buffer, 0, bufferSize);
                        bytesAvailable = fileInputStream.available();
                        bufferSize = Math.min(bytesAvailable, maxBufferSize);
                        buffer = new byte[bufferSize];
                        bytesRead = fileInputStream.read(buffer, 0, bufferSize);
                        }
    
                       outputStream.writeBytes(lineEnd);
    
    
    
                        outputStream.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
                        fileInputStream.close();
                            outputStream.close();
                        Log.d("RESPONSE","--"+connection.getResponseMessage());
        }
                       catch (Exception e) {
                        Log.i("Exception: ",e.toString());
    
                        // TODO: handle exception
                    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On Stackers' recommendation, I have been reading Crockford's excellent Javascript: The Good Parts .
Hi fellow stackers... I have an ASP.NET 3.5 app using forms authentication. I would
Good evening fellow stackers, I have a mutex and threaded related question about //
Greetings stackers, I'm trying to come up with the best database schema for an
I'm new to WordPress theming and have downloaded the Starker's WP theme from starkers
I have setup the following header file to create a Stack which uses an
For example. Lets say we have a stackpanel on a form. Its full of
Hello there fellow Stackers! I wonder if anybody could tell me what the following
My wife recently started a business making soap bars and the soap labels have
I'm getting all learned up about binding in WPF. I'm having a lot of

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.