使用RequestPart接收文件和参数,注意type不能设置为Integer类型
@PostMapping("/upload")
public Mono<Result<String>> upload(@RequestPart("file") FilePart file,
@RequestPart("type") String type) {
}
转换为byte数组处理
@PostMapping("/upload")
public Mono<Result<String>> upload(@RequestPart FilePart file) {
return DataBufferUtils.join(file.content()).map(dataBuffer -> dataBuffer.asByteBuffer().array()).map(bytes -> {
});
}
转换为InputStream处理
@PostMapping("/upload")
public Mono<Result<String>> upload( @RequestPart FilePart file) {
return DataBufferUtils.join(file.content()).map(dataBuffer -> dataBuffer.asInputStream()).map(ins -> {
});
}