Figured it (using regular POST).
On the Android (1.5) client side:
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.FileEntity;
import org.apache.http.impl.client.DefaultHttpClient;
public class FileUploader {
public static void uploadFile (File file, String sUrl) throws
ClientProtocolException, IOException {
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(sUrl);
FileEntity entity = new FileEntity(file, "binary/octet-stream");
request.setEntity(entity);
HttpResponse response = client.execute(request);
}
}
On the server side:
<%...@page import="org.jfree.io.IOUtils"%><%
File sensorLogFile = new File ("/var/tmp/sensorlog.dat");
java.io.OutputStream fout = new java.io.FileOutputStream
(sensorLogFile);
java.io.InputStream in = request.getInputStream();
IOUtils.getInstance().copyStreams(in,fout);
%>
On Jun 26, 3:53 pm, jdesbonnet <[email protected]> wrote:
> It's only day 2 for me on Android/Cupcake and generally finding it a
> breeze. But one thing is confounding me:
>
> I cannot get data files off the device to a server. A multipart POST
> request would be my choice. All examples I've tried to date either
> don't compile (missing classes eg "Part", or compile but don't work).
> Many people seem to be asking the same question and I'm surprised this
> is not one of the items on the developer's FAQ.
>
> I would really appreciate a pointer to a working code example for the
> latest API.
>
> Thanks in advance,
> Joe.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" 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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---