I need to receive an HTTP Post Multipart which contains only 2 parameters:
- JSON字符串
- 二进制文件
哪种身体摆放方式是正确的? 我将使用Chrome睡觉控制台测试HTTP调用,所以我想知道是否正确的解决方案是为json参数和二进制文件设置一个"label"键.
On the server side I'm using Resteasy 2.x, and I'm going to read the Multipart body like this:
@POST
@Consumes("multipart/form-data")
public String postWithPhoto(MultipartFormDataInput multiPart) {
Map <String, List<InputPart>> params = multiPart.getFormDataMap();
String myJson = params.get("myJsonName").get(0).getBodyAsString();
InputPart imagePart = params.get("photo").get(0);
//do whatever I need to do with my json and my photo
}
这是走这条路吗? 使用标识特定内容处置的键"myJsonName"检索我的JSON字符串是否正确? 有没有其他方法可以在一个HTTP多部分请求中接收这两个内容?
提前谢谢