| | |
| | |
|
| | | import java.io.File;
|
| | | import java.io.IOException;
|
| | | import java.nio.file.Paths;
|
| | | import java.util.Objects;
|
| | | import org.apache.commons.io.FilenameUtils;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | |
| | | import com.ruoyi.common.exception.file.FileSizeLimitExceededException;
|
| | | import com.ruoyi.common.exception.file.InvalidExtensionException;
|
| | | import com.ruoyi.common.utils.DateUtils;
|
| | | import com.ruoyi.common.utils.IdUtils;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.common.utils.uuid.Seq;
|
| | | import com.ruoyi.framework.config.RuoYiConfig;
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | String fileName = extractFilename(file);
|
| | |
|
| | | File desc = getAbsoluteFile(baseDir, fileName);
|
| | | file.transferTo(desc);
|
| | | String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
|
| | | file.transferTo(Paths.get(absPath));
|
| | | return getPathFileName(baseDir, fileName);
|
| | | }
|
| | |
|
| | |
| | | */
|
| | | public static final String extractFilename(MultipartFile file)
|
| | | {
|
| | | return DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + getExtension(file);
|
| | | return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
|
| | | FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file));
|
| | | }
|
| | |
|
| | | public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
|