feign传文件
以下为feign的单个文件上传,多文件和字节上传。
package com.bk.oss.inheritance; import com.bk.oss.command.UploadFilesCommand; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.util.Map; public interface OssApiService { @ApiOperation(value = "[WX-00101]文件上传", response = String.class, responseReference = "文件路径") @PostMapping( path = {"/oss/uploadFile"}, consumes = {"multipart/form-data"} ) String uploadFile(@ApiParam(name = "file", value = "文件") @RequestPart("file") MultipartFile file) throws IOException; @ApiOperation(value = "[WX-00102]文件上传【批量】", responseReference = "响应结果:key为文件的名称,value是文件上传后返回的路径", responseContainer = "map", response = String.class) @PostMapping( path = {"/oss/uploadFiles"}, consumes = {"multipart/form-data"} ) Map<String, String> uploadFiles(UploadFilesCommand uploadFIlesCommand) throws IOException; @ApiOperation(value = "[WX-00103]文件上传 (内部使用)", responseReference = "件路径") @PostMapping( path = "/oss/uploadFileByByte", consumes = {"multipart/form-data"} ) String uploadFileByByte(@RequestPart("bytes") byte[] bytes); }
package com.bk.oss.command; import io.swagger.annotations.ApiModel; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.Setter; import org.springframework.web.multipart.MultipartFile; @Data @NoArgsConstructor @AllArgsConstructor @Builder @ApiModel(value = "文件上传批量") @Setter(lombok.AccessLevel.PROTECTED) public class UploadFilesCommand { private MultipartFile[] files; private String[] fileNames; }
二.@requestParam和@requestPart区别
https://blog.csdn.net/wd2014610/article/details/79727061