Note that there are some explanatory texts on larger screens.

plurals
  1. POHTTP Post Multipart on Android not posting image.
    primarykey
    data
    text
    <p>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.</p> <p>Thanks! </p> <pre><code>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()); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload