|
|
|
@ -26,6 +26,10 @@ public class uploadController {
|
|
|
|
|
|
|
|
|
|
@Value("${file_path}")
|
|
|
|
|
private String filePath;
|
|
|
|
|
@Value("${file_url}")
|
|
|
|
|
private String fileUrl;
|
|
|
|
|
@Value("${file_lpath}")
|
|
|
|
|
private String fileLpath;
|
|
|
|
|
@Value("${minio_path}")
|
|
|
|
|
private String minioPath;
|
|
|
|
|
@Value("${minio_url}")
|
|
|
|
@ -121,23 +125,23 @@ public class uploadController {
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "上传文件只能是 jpg,png,doc,pdf 格式");
|
|
|
|
|
}
|
|
|
|
|
String newName = UUID.randomUUID() + fileType;//生成新文件名
|
|
|
|
|
String savePath = minioPath + "/register/file/" + type;
|
|
|
|
|
String fileFullName = savePath + "/" + newName;
|
|
|
|
|
String savePath = filePath + "/register/" + type;
|
|
|
|
|
String savePath1 = fileLpath + "?type=" + type;
|
|
|
|
|
|
|
|
|
|
// File file1 = new File(savePath);
|
|
|
|
|
// if (!file1.exists()) {// 判断目录是否存在
|
|
|
|
|
// file1.mkdirs();// 创建多层目录
|
|
|
|
|
// }
|
|
|
|
|
// file1 = new File(savePath + "/" + newName);
|
|
|
|
|
File file1 = new File(savePath);
|
|
|
|
|
if (!file1.exists()) {// 判断目录是否存在
|
|
|
|
|
file1.mkdirs();// 创建多层目录
|
|
|
|
|
}
|
|
|
|
|
file1 = new File(savePath + "/" + newName);
|
|
|
|
|
try {
|
|
|
|
|
// file.transferTo(file1);
|
|
|
|
|
MinioUtil.uploadFile(fileFullName, file);
|
|
|
|
|
file.transferTo(file1);
|
|
|
|
|
// MinioUtil.uploadFile(fileFullName, file);
|
|
|
|
|
Map<String, String> rMap = new HashMap<>();
|
|
|
|
|
rMap.put("msg", "上传成功");
|
|
|
|
|
rMap.put("name", minioUrl + fileFullName);
|
|
|
|
|
rMap.put("name", fileUrl + savePath1 + "&name=" + newName);
|
|
|
|
|
rMap.put("type", type);
|
|
|
|
|
return ResultVOUtils.success(rMap);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "上传失败");
|
|
|
|
|