使用DavidWebb for Android获取上传进度

时间:2015-08-31 15:54:29

标签: android httpurlconnection

我在这个答案中找到了要升级的代码:https://codereview.stackexchange.com/a/55472

Webb webb = Webb.create();
Response<String> response = webb
        .post("http://www.example.com/service")
        .body(new File("camera/myfile.jpg"))
        .connectTimeout(10 * 1000)
        .asString();

if (response.isSuccess()) {
    String outcome = response.getBody();

    // ...

} else {
    System.out.println(response.getStatusCode());
    System.out.println(response.getResponseMessage());
    System.out.println(response.getErrorBody());
}

但是如何跟踪上传的进度?

1 个答案:

答案 0 :(得分:0)

您可以看到多部分上传

enter image description here

此库的

不可用功能,因此您无法获得上传文件的进度。

您需要使用MultiPart将文件上传到服务器。更多here