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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:32:58+00:00 2026-06-03T00:32:58+00:00

I have to upload my image using HTTP Post request. Image will be posted

  • 0

I have to upload my image using HTTP Post request. Image will be posted to Parse server.

I found this documentation but I am not sure how to create an upload a image. I have a http request method, please correct me.

Here is the documentation.

public boolean uploadingFiles ( String tempFilePath ) {
        String filePath = null ;
        String fileName = null ;
        boolean flag = false ;
        try {
            filePath = tempFilePath ;
            fileName = new String ( filePath ) ;
            fileName = filePath.substring ( filePath.lastIndexOf ( "/" ) + 1 , filePath.length ( ) ) ;
        } catch ( Exception e ) {
            Log.e ( "Exception" , "uploadingFiles Message = " + e.toString ( ) ) ;
        }

        HttpClient httpclient = new DefaultHttpClient ( ) ;
        try {

            HttpPost httppost = new HttpPost ( "https://api.parse.com/1/files/" ) ;
            StringBody filename = new StringBody ( fileName ) ;
            File f = new File ( filePath ) ;
            FileBody bin = new FileBody ( f ) ;

            MultipartEntity reqEntity = new MultipartEntity ( ) ;
            reqEntity.addPart ( "X-Parse-Application-Id" , new StringBody("MY KEY" )) ;
            reqEntity.addPart ( "X-Parse-REST-API-Key" , new StringBody("My KEY" )) ;
            reqEntity.addPart ( "Content-Type:" , new StringBody("image/png" )) ;
            reqEntity.addPart ( "file:" , bin ) ;

            httppost.setEntity ( reqEntity ) ;

            System.out.println ( "executing request " + httppost.getRequestLine ( ) ) ;
            HttpResponse response = httpclient.execute ( httppost ) ;
            HttpEntity resEntity = response.getEntity ( ) ;

            System.out.println ( "----------------------------------------" ) ;
            System.out.println ( response.getStatusLine ( ) ) ;
            if ( resEntity != null ) {
                System.out.println ( "Response content length: " + resEntity.getContentLength ( ) ) ;
                InputStream is = resEntity.getContent ( ) ;
                if ( is != null ) {
                    Writer writer = new StringWriter ( ) ;

                    char [ ] buffer = new char [ 1024 ] ;
                    try {
                        Reader reader = new BufferedReader ( new InputStreamReader ( is , "UTF-8" ) ) ;
                        int n ;
                        while ( ( n = reader.read ( buffer ) ) != - 1 ) {
                            writer.write ( buffer , 0 , n ) ;
                        }
                    } finally {
                        is.close ( ) ;
                    }
                    String serverResult = writer.toString ( ) ;
                    System.out.println ( "Response content: " + serverResult ) ;
                } else {
                    System.out.println ( "Response nothing: " ) ;
                }
            }
            EntityUtils.consume ( resEntity ) ;
        } catch ( Exception e ) {
            e.printStackTrace ( ) ;
        } finally {
            try {
                httpclient.getConnectionManager ( ).shutdown ( ) ;
            } catch ( Exception ignore ) {
            }
        }
        return flag ;
    }
  • 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-03T00:33:00+00:00Added an answer on June 3, 2026 at 12:33 am

    This is what i currently use

            try
        {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            bitmap.compress(CompressFormat.JPEG, 100, bos);
            byte[] data = bos.toByteArray();
    
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, timeout);
            HttpConnectionParams.setSoTimeout(httpParameters, timeout);
            HttpClient httpClient = new DefaultHttpClient(httpParameters);
    
            HttpPost postRequest = new HttpPost(URL_SEND);
    
            ByteArrayBody bab = new ByteArrayBody(data, "Feest" + pad(random.nextInt(9999) + 1) + ".jpg");
            MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
            reqEntity.addPart("Filedata", bab);
            reqEntity.addPart("dropboxId", new StringBody(URLEncoder.encode(uid)));
            postRequest.setEntity(reqEntity);
    
            HttpResponse response = httpClient.execute(postRequest);
            BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
            String sResponse;
            StringBuilder s = new StringBuilder();
    
            while((sResponse = reader.readLine()) != null)
            {
                s = s.append(sResponse);
            }
    
            if(d) Log.i(E, "Send response:\n" + s);
        }
        catch (Exception e)
        {
            if(d) Log.e(E, "Error while sending: " + e.getMessage());
            return ERROR;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to upload a given image using Amazon S3 I have this PHP:
I'm trying to send an image to a server, using HTTP Post Multipart. Everything
I have implemented the image upload code using jquery php in my php web
I have an image upload function that supports multiple files upload, but somehow it
After research I have figured out how to upload an image to my server
I want to make http form post using NSURLConnection in iOS. I have two
Following on from my post.. Saving an image from HTTP POST (Not using FileUpload
I simply want to upload an image to a server with POST. As simple
I am trying to upload the image using the webservices and Base64string. But each
I need to upload some data on a site, using a POST request. I

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.