|
@@ -1,13 +1,12 @@
|
|
package com.usky.dxtop.common.utils.file;
|
|
package com.usky.dxtop.common.utils.file;
|
|
|
|
|
|
import com.usky.dxtop.common.config.DxConfig;
|
|
import com.usky.dxtop.common.config.DxConfig;
|
|
-import com.usky.dxtop.common.constant.Constants;
|
|
|
|
import com.usky.dxtop.common.exception.file.FileNameLengthLimitExceededException;
|
|
import com.usky.dxtop.common.exception.file.FileNameLengthLimitExceededException;
|
|
import com.usky.dxtop.common.exception.file.FileSizeLimitExceededException;
|
|
import com.usky.dxtop.common.exception.file.FileSizeLimitExceededException;
|
|
import com.usky.dxtop.common.exception.file.InvalidExtensionException;
|
|
import com.usky.dxtop.common.exception.file.InvalidExtensionException;
|
|
-import com.usky.dxtop.common.utils.DateUtils;
|
|
|
|
import com.usky.dxtop.common.utils.StringUtils;
|
|
import com.usky.dxtop.common.utils.StringUtils;
|
|
import com.usky.dxtop.common.utils.uuid.IdUtils;
|
|
import com.usky.dxtop.common.utils.uuid.IdUtils;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.io.FilenameUtils;
|
|
import org.apache.commons.io.FilenameUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
@@ -20,6 +19,7 @@ import java.io.IOException;
|
|
*
|
|
*
|
|
* @author yq
|
|
* @author yq
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
public class FileUploadUtils
|
|
public class FileUploadUtils
|
|
{
|
|
{
|
|
/**
|
|
/**
|
|
@@ -113,7 +113,8 @@ public class FileUploadUtils
|
|
String fileName = extractFilename(file);
|
|
String fileName = extractFilename(file);
|
|
|
|
|
|
File desc = getAbsoluteFile(baseDir, fileName);
|
|
File desc = getAbsoluteFile(baseDir, fileName);
|
|
- file.transferTo(desc);
|
|
|
|
|
|
+// file.transferTo(desc);
|
|
|
|
+// FileUtils.copyInputStreamToFile(file.getInputStream(),desc);
|
|
String pathFileName = getPathFileName(baseDir, fileName);
|
|
String pathFileName = getPathFileName(baseDir, fileName);
|
|
return pathFileName;
|
|
return pathFileName;
|
|
}
|
|
}
|
|
@@ -125,7 +126,7 @@ public class FileUploadUtils
|
|
{
|
|
{
|
|
String fileName = file.getOriginalFilename();
|
|
String fileName = file.getOriginalFilename();
|
|
String extension = getExtension(file);
|
|
String extension = getExtension(file);
|
|
- fileName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
|
|
|
|
|
|
+ fileName = IdUtils.fastUUID() + "." + extension;
|
|
return fileName;
|
|
return fileName;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -145,10 +146,7 @@ public class FileUploadUtils
|
|
|
|
|
|
private static final String getPathFileName(String uploadDir, String fileName) throws IOException
|
|
private static final String getPathFileName(String uploadDir, String fileName) throws IOException
|
|
{
|
|
{
|
|
- int dirLastIndex = DxConfig.getProfile().length() + 1;
|
|
|
|
- String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
|
|
|
|
- String pathFileName = Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
|
|
|
|
- return pathFileName;
|
|
|
|
|
|
+ return String.format("%s/%s",uploadDir,fileName);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|