参数接收为 List
forEach循环上传 最后将上传链接list返回即可
@Override
public GraceJSONResult uploadSomeFiles(String userId, List<MultipartFile> files) {
if (StringUtils.isBlank(userId)) {
GraceException.display(ResponseStatusEnum.USER_NOT_EXIST_ERROR);
}
if (files == null && files.size() <= 0) {
GraceException.display(ResponseStatusEnum.FILE_UPLOAD_NULL_ERROR);
}
List<String> imageList = new ArrayList<>();
files.forEach((file) -> {
try {
String realPath = uploadService.uploadFile(file, userId);
reviewImage(realPath);
imageList.add(realPath);
} catch (IOException e) {
e.printStackTrace();
}
});
return GraceJSONResult.ok(imageList) ;
}