From 1eedb8a57c2eb5c9953dcf058184ebdc6987fbf5 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 24 May 2022 15:14:21 +0800
Subject: [PATCH] Merge branch 'feature/订单服务单代码改造' into alpha
---
zq-erp/src/main/java/com/matrix/system/common/tools/UploadUtil.java | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/common/tools/UploadUtil.java b/zq-erp/src/main/java/com/matrix/system/common/tools/UploadUtil.java
index d3b7269..3f70c38 100644
--- a/zq-erp/src/main/java/com/matrix/system/common/tools/UploadUtil.java
+++ b/zq-erp/src/main/java/com/matrix/system/common/tools/UploadUtil.java
@@ -2,6 +2,8 @@
import com.matrix.core.tools.*;
import com.matrix.system.common.constance.AppConstance;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@@ -23,7 +25,13 @@
* @email 935090232@qq.com
* @date 2018年6月15日
*/
+@Component
public class UploadUtil {
+ @Value("${file_storage_path}")
+ private String fileStoragePath;
+
+ @Value("${static_resource_url}")
+ private String staticResourceUrl;
private static String STATUSS = "status";
private static String MSG = "msg";
@@ -43,14 +51,14 @@
* @throws IOException
*/
- public static Map<String, String> doUpload(MultipartHttpServletRequest request, List<FileType> extList,
+ public Map<String, String> doUpload(MultipartHttpServletRequest request, List<FileType> extList,
String folderType, Long userId) throws NoSuchAlgorithmException, IOException {
Map<String, String> resourceMap = new HashMap<>();
// 图片保存目录路径
- String baseSavePath = PropertiesUtil.getString(AppConstance.FILES_TORAGE_PATH);
+ String baseSavePath =fileStoragePath;
// 图片保存目录URL
- String baseSaveUrl = PropertiesUtil.getString(AppConstance.NGINX_URL);
+ String baseSaveUrl = staticResourceUrl;
LogUtil.debug("图片保存目录路径={}",baseSavePath);
LogUtil.debug("图片保存目录URL={}",baseSaveUrl);
@@ -89,7 +97,7 @@
String newFileName = UUIDUtil.getRandomID() + "." + fileExt;
Map<String, String> fileUrlMap = fileUrl(baseSavePath, baseSaveUrl, folderType, userId);
String savePath = fileUrlMap.get("savePath");
- String saveUrl = fileUrlMap.get("saveUrl");
+ String saveUrl = fileUrlMap.get("saveUrl").replaceAll("\\\\","/");
File uploadedFile = new File(savePath, newFileName);
try {
FileCopyUtils.copy(file.getBytes(), uploadedFile);
--
Gitblit v1.9.1