Commit 3b9cdcb8 by 墨竹

fix:上传文件名字修改

parent 4be19ace
...@@ -49,15 +49,14 @@ public class UploadController extends WebBaseController { ...@@ -49,15 +49,14 @@ public class UploadController extends WebBaseController {
String suffix = name.substring(name.lastIndexOf(".") + 1); String suffix = name.substring(name.lastIndexOf(".") + 1);
name = SecureUtil.md5(name) + "." + suffix; name = SecureUtil.md5(name) + "." + suffix;
String location = System.getProperty("user.dir") + "/data/tmp/"; String location = System.getProperty("user.dir") + "/data/tmp/";
//b
long len = file.getSize(); long len = file.getSize();
File templateFile = new File(location + name); File templateFile = new File(location + name);
FileUtils.copyInputStreamToFile(file.getInputStream(), templateFile); FileUtils.copyInputStreamToFile(file.getInputStream(), templateFile);
// 2.上传腾讯云 // 2.上传腾讯云
String dayFilePath = LocalDateTime.now().format(DateTimeFormatter.ofPattern(DateUtil.FORMAT_DATETIME_14)); String dayFilePath = LocalDateTime.now().format(DateTimeFormatter.ofPattern(DateUtil.FORMAT_DATETIME_14));
String nameUpload = mediaName + "." + suffix;
String key = "haoban/" + dayFilePath + "/" + mediaName; String key = "haoban/" + dayFilePath + "/" + nameUpload;
fileType = FILE_TYPE.contains(fileType) ? fileType : BucketNameEnum.OTHER_90000.getName(); fileType = FILE_TYPE.contains(fileType) ? fileType : BucketNameEnum.OTHER_90000.getName();
try { try {
String url = FileUploadUtil.simpleUploadFileFromLocal(templateFile, key, fileType); String url = FileUploadUtil.simpleUploadFileFromLocal(templateFile, key, fileType);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment