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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:45:50+00:00 2026-06-01T02:45:50+00:00

The whole thing works perfectly, except image won’t show, no errors, Using RoR. What

  • 0

The whole thing works perfectly, except image won’t show, no errors, Using RoR. What am I missing? All called by async class btw. Been trying several different methods with no avail, if someone could help me out that would be great. Willing to post more if needed.

Thanks!

public static void multiPart(Bitmap image, String topicid, String topost, Context c){
        String responseString = "";
        {
            try {
                String imageName = System.currentTimeMillis() + ".jpg";
                HttpClient httpClient = new MyHttpClient(c);
                HttpPost postRequest = new HttpPost("https://urlofmyapi");
                if (image==null){
                    Log.d("TAG", "NULL IMAGE");
                }
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                image.compress(CompressFormat.JPEG, 75, bos);
                byte[] data = bos.toByteArray();
                ByteArrayBody bab = new ByteArrayBody(data, imageName);
                MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
                reqEntity.addPart("feed", new StringBody(topost));
                reqEntity.addPart("post_to", new StringBody(topicid));
                reqEntity.addPart("upload_file", bab);
                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);
                }
                responseString = s.toString();
              System.out.println("Response: " + responseString);
            } catch (Exception e) {
                Log.e(e.getClass().getName(), e.getMessage());
            }
          }
        }
  • 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-01T02:45:51+00:00Added an answer on June 1, 2026 at 2:45 am

    HTTP POSTing images from Java to RoR always seems to have undue issues for me. Have you tried attaching the binary as a org.apache.http.entity.mime.content.FileBody object, like this Android Multipart Upload question?

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

Sidebar

Related Questions

Edit: Works perfectly in debugger now, but block doesn't rotate at all when run
I am new to the whole MVP thing and slowly getting my head around
I'm new to this whole Joomla thing, and I'm trying to get an swf
I'm just starting out with the whole ajax thing and I need some help.
I have been looking at monotorrent and while investigating the whole bittorrent thing I
(I'm a mac user) I'm new at this whole programing thing. its been explained
Alright, I thought I had this whole setTimeout thing perfect but I seem to
I'm very confused about the whole user profile thing in drupal, hope someone can
I'm trying to get familiar with the whole keyboard event detection thing. Here's my
This is kind of a brainteaser question, since the code works perfectly fine as-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.