本文整理汇总了Java中org.apache.http.entity.ContentType.MULTIPART_FORM_DATA属性的典型用法代码示例。如果您正苦于以下问题:Java ContentType.MULTIPART_FORM_DATA属性的具体用法?Java ContentType.MULTIPART_FORM_DATA怎么用?Java ContentType.MULTIPART_FORM_DATA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.http.entity.ContentType
的用法示例。
在下文中一共展示了ContentType.MULTIPART_FORM_DATA属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadWelcomeMessage
public ApiResponse uploadWelcomeMessage(String filePath, int messageId, int selectedMessageId) {
File file = new File(filePath);
HttpPost uploadRequest = new HttpPost(WELCOME_MESSAGE_URI);
StringBody commandeBody = new StringBody("annonce_mess", ContentType.MULTIPART_FORM_DATA);
StringBody messageIdBody = new StringBody(String.valueOf(messageId), ContentType.MULTIPART_FORM_DATA);
StringBody maxFileSizeBody = new StringBody("5242880", ContentType.MULTIPART_FORM_DATA);
StringBody selectMessageBody = new StringBody(String.valueOf(selectedMessageId),
ContentType.MULTIPART_FORM_DATA);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addBinaryBody("FILE", file, ContentType.create("audio/mp3"), "message.mp3");
builder.addPart("commande", commandeBody);
builder.addPart("id_message", messageIdBody);
builder.addPart("id_message_select", selectMessageBody);
builder.addPart("MAX_FILE_SIZE", maxFileSizeBody);
HttpEntity entity = builder.build();
uploadRequest.setEntity(entity);
HttpResponse response = executeRequest(uploadRequest);
return new ApiResponse(HttpStatus.gethttpStatus(response.getStatusLine().getStatusCode()));
}