我有一个简单的数据结构:
public class FileUpdateRequest {
private static final String JSON_FILE_NAME = "fileName";
private static final String JSON_FILE = "file";
private final String fileName;
private final InputStream inputStream;
private final FormDataContentDisposition contentDisposition;
public FileUpdateRequest(@JsonProperty(JSON_FILE_NAME) String fileName,
@FormDataParam(JSON_FILE) InputStream inputStream,
@FormDataParam(JSON_FILE) FormDataContentDisposition contentDisposition) {
this.fileName = fileName;
this.inputStream = inputStream;
this.contentDisposition = contentDisposition;
}
@JsonProperty(JSON_FILE_NAME)
public String getFileName() {
return fileName;
}
@FormDataParam(JSON_FILE)
public InputStream getInputStream() {
return inputStream;
}
@FormDataParam(JSON_FILE)
public FormDataContentDisposition getContentDisposition() {
return contentDisposition;
}
我想在我的REST服务中有一个可以接受UpdateRequest列表的终结点:
例如:
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes({MediaType.MULTIPART_FORM_DATA, MediaType.APPLICATION_FORM_URLENCODED})
@Path("/path")
MyResponse endpointMethod(List<UpdateRequest> request)
我正在使用Jersey,但是我对查看cURL请求发送FileUpdateRequest列表的外观更感兴趣。