throw new RuntimeException(e);
}
parts.add(filePart);
}
MultipartRequestEntity requestEntity = new MultipartRequestEntity(parts.toArray(new Part[parts.size()]), new FluentCaseInsensitiveStringsMap());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
requestEntity.writeRequest(baos);
} catch (IOException e) {
throw new RuntimeException(e);
}
InputStream body = new ByteArrayInputStream(baos.toByteArray());
String contentType = requestEntity.getContentType();
Http.Header header = new Http.Header();
header.name = "content-type";
header.values = Arrays.asList(new String[]{contentType});
request.headers.put("content-type", header);
return POST(request, url, MULTIPART_FORM_DATA, body);