Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid/rails multipart upload problem
    primarykey
    data
    text
    <p>My problem is that I try to upload an image and some text values to an rails server, and the text values end up as files, insted of just param values.</p> <p>How the post looks on the server</p> <pre><code>Parameters: {"action"=&gt;"create", "controller"=&gt;"problems", "problem"=&gt;{"lon"=&gt;#File:/tmp/RackMultipart20100404-598-8pi1vj-0&gt;, "photos_attributes"=&gt;{"0"=&gt;{"image"=&gt;#File:/tmp/RackMultipart20100404-598-pak6jk-0&gt;}}, "subject"=&gt;#File:/tmp/RackMultipart20100404-598-nje11p-0&gt;, "category_id"=&gt;#File:/tmp/RackMultipart20100404-598-ijy1oo-0&gt;, "lat"=&gt;#File:/tmp/RackMultipart20100404-598-1a7140w-0&gt;, "email"=&gt;#File:/tmp/RackMultipart20100404-598-1b7w6jp-0&gt;}} </code></pre> <p>part of the android code</p> <pre><code>try { File file = new File(Environment.getExternalStorageDirectory(),"FMS_photo.jpg"); HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://homepage.com/path"); FileBody bin = new FileBody(file); Charset chars = Charset.forName("UTF-8"); MultipartEntity reqEntity = new MultipartEntity(); reqEntity.addPart("problem[photos_attributes][0][image]", bin); reqEntity.addPart("problem[category_id]", new StringBody("17", chars)); post.setEntity(reqEntity); HttpResponse response = client.execute(post); HttpEntity resEntity = response.getEntity(); if (resEntity != null) { resEntity.consumeContent(); } return true; } catch (Exception ex) { globalStatus = UPLOAD_ERROR; serverResponse = ""; return false; } finally { } </code></pre>
    singulars
    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.
    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