@requestpart的示例和说明

问题描述

要求是用户将使用angular将文件上传到spring boot(ReST请求)。 ReST界面将文件存储到gitlab中以进行进一步处理。使用@RequestPart批注,将从请求中检索具有不同名称的内容并将其放入Gitlab。实现将如下所示:

    @ApiOperation(value = "Upload java files into Gitlab")
    @RequestMapping(method = RequestMethod.POST,consumes = MediaType.MULTIPART_FORM_DATA_VALUE,produces = "application/json")
    @ApiResponses(value = { @ApiResponse(code = 200,response = CustomResponse.class,message = "Success"),@ApiResponse(code = 400,response = ErrorResponse.class,message = "Bad Request"),@ApiResponse(code = 500,message = "Internal Server Error") })

    public CustomResponse uploadJava(
            @ApiParam(value = "Interface",required = true)
            @RequestPart(name = "interface",required = true) final MultipartFile interfaceClass,@ApiParam(value = "Java Class",required = false) 
            @RequestPart(name = "javaClass",required = false) final MultipartFile javaClass) {
        return null;
    }

我的问题是

  1. 如何添加上述说明和示例。 (如同 RequestParam)
  2. 如何为每个文件设置内容类型。

注意:

  1. 我尝试修改@RequestParam而不是@RequestPart。在这个 在这种情况下,仅第二个文件(“ javaclass”)被推送到了春季启动。
  2. 我当前的POM
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

致谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...