Spring通过FeignClient调用文件上传服务上传本地磁盘文件代码如下:
//2. 图片解码并保存
String filename = UUID.randomUUID() + ".jpg";//文件名+后缀名
String originalFilename = uploadPath + tbYingqushebei.getCampId() + File.separator + filename;
log.info("图片路径:{}", uploadPath + tbYingqushebei.getCampId() + File.separator + filename);
FileUtils.generateImage(zhoujieruqingaojingjiluAO.getGaojingtupian(), originalFilename);
File originalFile = new File(originalFilename);
DiskFileItem fileItem = new DiskFileItem("file", "image/jpeg", false, originalFile.getName(), (int) originalFile.length(), originalFile.getParentFile());
try (InputStream input = new FileInputStream(originalFile); OutputStream os = fileItem.getOutputStream()) {
IOUtils.copy(input, os);
log.info(fileItem.getStoreLocation() + "--getStoreLocation");
} catch (Exception e) {
throw new IllegalArgumentException("Invalid file:" + e, e);
}
MultipartFile multipartFile = new CommonsMultipartFile(fileItem);
// 调用文件上传服务上传告警图片
R<SysFile> file = remoteFileService.upload(multipartFile);
SysFile sysFile = file.getData();
if (ObjectUtils.isNotEmpty(originalFile) && originalFile.exists()) {
originalFile.delete();
}
log.info("周杰告警图片url--{}", sysFile.getUrl());
最新评论
网飞没问题, 迪士尼+有解决方案么?
pp助手是安卓手机用的,根本下载用不来苹果
已解决
这样的话数据库里的结构为{"attachment":{"content":"xxx"}}, 要怎么才能变成{"content":"xxx"},从而使结构保持一致?
赞! make test不过的坑都写到的,谢谢楼主~
谢谢你
用了root用户还是一直502是怎么回事呢
student id 是空的