I'm working on an application that does an upload to a webserver, but
struggling with the actual fileupload.. code:

byte[] data = params[0]; // this is my picture data in a ByteArray

HttpClient httpClient = new DefaultHttpClient();

HttpPost request = new HttpPost("http://www.someurl.com/upload.aspx";);

List<BasicNameValuePair> nameValuePairs = new
ArrayList<BasicNameValuePair>();
nameValuePairs.add(new BasicNameValuePair
("filename","droidUpload.jpg"));
nameValuePairs.add(new BasicNameValuePair("userfile", ?????) // how do
I add my byte array, obviously can't go here.

request.setEntity(new UrlEncodedFormEntity(nameValuePairs));

Now, I have this working with what is no longer supported in
MultipartEntity as follows:

MultipartEntity  entity = new MultipartEntity();
entity.addPart("filename",new StringBody("droidUpload.jpg"));
entity.addPart("userfile[]", new InputStreamBody(new
ByteArrayInputStream(data), "droidUpload.jpg"));
request.setEntity(entity);

Problem is MultipartEntity is apparently no longer supported, although
I found the libraries I can include in my project, so I'm hoping I"m
just missing something stupid here.

--

You received this message because you are subscribed to the Google Groups 
"Android Discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/android-discuss?hl=en.


Reply via email to