jyy
2022-04-15 f57554f7da5e4d05b4b4bab99bf49ac9ca8c2038
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);