feign传文件

以下为feign的单个文件上传,多文件和字节上传。

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);

}
View Code

 

 feign传文件

 

 

 

feign传文件
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;

}
View Code

 二.@requestParam和@requestPart区别

https://blog.csdn.net/wd2014610/article/details/79727061

上一篇:PHP 大文件上传代码(500M以上)


下一篇:【转】使用Linux下Docker部署MSSQL并加载主机目录下的数据库