!310 完善ruoyi-file模块的upload接口在文件过大和文件名过长的情况下的返回值中的msg提示信息
Merge pull request !310 from pigwantacat/master
| | |
| | | {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | public FileException(String code, Object[] args)
|
| | | public FileException(String code, Object[] args, String msg)
|
| | | {
|
| | | super("file", code, args, null);
|
| | | super("file", code, args, msg);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | public FileNameLengthLimitExceededException(int defaultFileNameLength)
|
| | | {
|
| | | super("upload.filename.exceed.length", new Object[] { defaultFileNameLength });
|
| | | super("upload.filename.exceed.length", new Object[] { defaultFileNameLength }, "the filename is too long");
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | public FileSizeLimitExceededException(long defaultMaxSize)
|
| | | {
|
| | | super("upload.exceed.maxSize", new Object[] { defaultMaxSize });
|
| | | super("upload.exceed.maxSize", new Object[] { defaultMaxSize }, "the filesize is too large");
|
| | | }
|
| | | }
|
| | |
| | | import java.io.IOException;
|
| | | import java.nio.file.Paths;
|
| | | import java.util.Objects;
|
| | |
|
| | | import com.ruoyi.common.core.exception.file.FileException;
|
| | | import org.apache.commons.io.FilenameUtils;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import com.ruoyi.common.core.exception.file.FileNameLengthLimitExceededException;
|
| | |
| | | {
|
| | | return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
|
| | | }
|
| | | catch (FileException fe){
|
| | | throw new IOException(fe.getDefaultMessage(), fe);
|
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | throw new IOException(e.getMessage(), e);
|