Does http in Android has a multiple-part-form-request just like the multipartFormRequestWithMethod
in AFNetWorking lib from Objective-c? I am using https://github.com/kevinsawicki/http-request
I wonder how to send multipart http request on Android. Any ideas, thanks in advance.
EDIT
I am using this way, adding several jars as suggested by this thread, but turns out it fails somewhere, any ideas?
private void uploadBlocksCommit(String commiturl, boolean update, String _uploadpath, String name, int fileSize, List<String> allblocks) throws IOException {
HttpRequest req = prepareApiPostRequest(commiturl, true, null);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addTextBody("csrfmiddlewaretoken", "n8ba38951c9ba66418311a25195e2e380");
if (update) {
builder.addTextBody("replace", "1");
}
builder.addTextBody("parent_dir", _uploadpath);
builder.addTextBody("file_name", name);
builder.addTextBody("file_size", String.valueOf(fileSize));
builder.addTextBody("csrfmiddlewaretoken", "n8ba38951c9ba66418311a25195e2e380");
builder.addTextBody("blockids", allblocks.toString()); // don`t assemble strings in allblocks
HttpEntity entity = builder.build();
req.send(entity.getContent());
}