Android 如何将curl命令传输到HTTPPOST请求

Android 如何将curl命令传输到HTTPPOST请求,android,facebook,http,curl,Android,Facebook,Http,Curl,我正在使用facebook对象api将图像上传到facebook登台服务。api文档在这里 在doucement中,它使用curl上载图像: curl-X POST-F file=@images/prawn-curry-1.jpg-F access\u token=$USER\u access\u token 如何在android应用程序中使用http post请求实现相同的功能 非常感谢 如果你知道如何从安卓系统发布照片,这应该不会有什么不同 Bundle params = new Bund

我正在使用facebook对象api将图像上传到facebook登台服务。api文档在这里

在doucement中,它使用curl上载图像:

curl-X POST-F file=@images/prawn-curry-1.jpg-F access\u token=$USER\u access\u token

如何在android应用程序中使用http post请求实现相同的功能


非常感谢

如果你知道如何从安卓系统发布照片,这应该不会有什么不同

Bundle params = new Bundle();
params.putByteArray("file", data);

Request request = new Request(
    Session.getActiveSession(),
    "me/staging_resources",
    params,
    HttpMethod.POST
);
Response response = request.executeAndWait();
// handle the response

我猜这里的数据是从文件中读取的字节数组。如果我能直接使用文件路径就更好了。我使用了MultipartEntity,它可以工作。如果我们可以在facebook sdk中使用带有文件路径的请求,那就太好了
String uri = "https://graph.facebook.com/me/staging_resources";
HttpResponse response = null;
try {        
    HttpClient client = new DefaultHttpClient();
    HttpPost post = new HttpPost(uri);
    MultipartEntity postEntity = new MultipartEntity();
    String picPath = (Uri.parse(picUriStr)).getPath();
    File file = new File("/data/local/tmp/images.jpg");
    postEntity.addPart("file", new FileBody(file, "image/jpeg"));
    postEntity.addPart("access_token", new StringBody("your access token string here"));
    post.setEntity(postEntity);
    response = client.execute(post);
}
catch (ClientProtocolException e) {
    Log.d(TAG, "exception");
    e.printStackTrace();
}
catch (IOException e) {
    Log.d(TAG, "exception");
    e.printStackTrace();
}   

HttpEntity responseEntity = response.getEntity();
if (responseEntity== null) {
    Log.d(TAG, "responseEntity is null");
    return "";
}