I've just created a simple solution for this: android_multipart_entity.
I've just created a simple solution for this: android_multipart_entity. It's free (including for commercial usage), however if this is possible please keep references to me inside of my classes. It's designed to be used with the built in Android HttpClient.
Sample usage code: HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("yourhost.com"); MultipartEntity entity = new MultipartEntity(); entity. AddPart(new StringPart("name", "yourname")); File imageFile = // .. get your image file entity. AddPart(new FilePart("picture", imageFile, null, "image/jpeg")); httppost.
SetEntity(entity); HttpResponse httpResponse = httpclient. Execute(httppost); EDIT: I reviewed your MultiPart with HttpURLConnection code. You get UTF-8 issue because of DataOutputStream usage.
API says for that class: Wraps an existing OutputStream and writes big-endian typed data to it. Typically, this stream can be read in by DataInputStream. This class just does not suit your needs.In order to read the data you would have to have its direct opposite - DataInputStream on the other end.
So my advice would be to use plain OutputStream. And write bytes to it. Smth like this: outputStream.
Write(partSeparator.getBytes()); outputStream. Write(("Content-Disposition: form-data; name=\"" + parameter.getKey() + "\"" + lineEnd).getBytes()); outputStream. Write(("Content-Type: text/plain; charset=UTF-8" + lineEnd).getBytes()); outputStream.
Write(("Content-Transfer-Encoding: 8bit" + lineEnd).getBytes()); outputStream. Write(lineEnd.getBytes()); outputStream. Write(parameter.getValue().
GetBytes("UTF-8")); // Write(lineEnd.getBytes()); outputStream. Write(partSeparator.getBytes()).
Thanks, looks great, altough the file upload not works :( – Sandor Nov 18 at 15:57 Hm, I successfully use this. What exactly goes wrong? What errors do you get in the LogCat?
Could it be a server issue? Do you specify internet permission in the android manifest? – Arhimed Nov 18 at 16:28 Could be a server issue.
I can post the files with my class which relies on HTTPURLConnection. I composed the multipart communication manually there. The server requires a line break before the file binary data, I don't know if this is standard.
The server is a php server. I have to solve this asap. I will look into the code deeply.
– Sandor Nov 19 at 11:41 To answer your question, no error at all, just the files didn't arrive to the server – Sandor Nov 19 at 11:43 @Sandor: Sorry, but I didn't catch you - have you tried my solution or not? It sounds like not. I successfully use my solution with php and ruby servers, so I can guarantee it works.
– Arhimed Nov 19 at 12:24.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.