使用内容类型multipart/related的Spring REST控制器

使用内容类型multipart/related的Spring REST控制器,spring,spring-mvc,Spring,Spring Mvc,我需要使用内容类型为multipart/related来编写SpringREST控制器。我不能让它工作。 以下代码适用于内容类型为content-type multipart/form-data //working code with content-type multipart/form-data// @RequestMapping(method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @Res

我需要使用内容类型为
multipart/related
来编写SpringREST控制器。我不能让它工作。 以下代码适用于内容类型为
content-type multipart/form-data

//working code with content-type multipart/form-data//
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public FileMetadataResource post(
        @Validated({ Default.class, PostCheck.class }) @RequestPart("resource") FileMetadataResource resource,
        @RequestPart("file") MultipartFile file) {
    return fileService.create(resource, file);
}
我做了一点调查,发现了以下问题

1) .getParts()仅适用于
多部分/表单数据
2) 由于Spring依赖于底层的ServletAPI,因此我无法找到任何方法来获取内容类型为
multipart/related
部分

我不确定我错过了什么。请帮助我如何实现内容类型为
multipart/related
的POST方法

谢谢,
Raj

您可能只需要使用输入流并自己解析就被卡住了,在servlet规范中没有看到对
multipart/related
的支持。我正在尝试,但是inputStream已经被spring framework读取,并且已经关闭。这里是错误
java.lang.IllegalStateException:getInputStream()已在org.apache.catalina.connector.request.getReader(request.java:1189)org.apache.catalina.connector.RequestFacade.getReader(RequestFacade.java:503)为该请求调用。
您能在create方法中发布代码吗?