Compare commits
4 Commits
8fff6522d9
...
c692101bfc
Author | SHA1 | Date |
---|---|---|
|
c692101bfc | |
|
723c28b1c6 | |
|
6a4ebb885b | |
|
b2caeb3999 |
1
pom.xml
1
pom.xml
|
@ -107,7 +107,6 @@
|
||||||
<artifactId>velocity-engine-core</artifactId>
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
<version>${velocity.version}</version>
|
<version>${velocity.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- collections工具类 -->
|
<!-- collections工具类 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-collections</groupId>
|
<groupId>commons-collections</groupId>
|
||||||
|
|
|
@ -137,7 +137,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-http</artifactId>
|
<artifactId>hutool-http</artifactId>
|
||||||
<version>5.3.3</version>
|
<version>5.8.16</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-core</artifactId>
|
||||||
|
<version>5.8.16</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -3,7 +3,12 @@ package com.ruoyi.common.utils.file;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import cn.hutool.core.img.ImgUtil;
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.config.RuoYiConfig;
|
import com.ruoyi.common.config.RuoYiConfig;
|
||||||
|
@ -114,9 +119,42 @@ public class FileUploadUtils
|
||||||
|
|
||||||
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
|
String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath();
|
||||||
file.transferTo(Paths.get(absPath));
|
file.transferTo(Paths.get(absPath));
|
||||||
|
makeMiniImage(absPath);
|
||||||
return getPathFileName(baseDir, fileName);
|
return getPathFileName(baseDir, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void makeMiniImage(String absPath) {
|
||||||
|
try {
|
||||||
|
String ext = FileUtils.getFileExt(absPath).toLowerCase();
|
||||||
|
String exts = Arrays.toString(new String[]{"jpg", "jpeg", "png", "bmp"});
|
||||||
|
if (exts.contains(ext)) {
|
||||||
|
if (new File(absPath).exists()) {
|
||||||
|
int w = ImgUtil.read(FileUtil.file(absPath)).getWidth();
|
||||||
|
if(w>2000) {
|
||||||
|
ImgUtil.scale(FileUtil.file(absPath),
|
||||||
|
FileUtil.file(absPath), (float) (2000.0 / w));
|
||||||
|
}
|
||||||
|
ImgUtil.scale(FileUtil.file(absPath),
|
||||||
|
FileUtil.file(absPath + ".min.jpg"), (float) (300.0 / w));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
List<File> list= FileUtil.loopFiles("D:/hahaprj/tmp");
|
||||||
|
for(File f :list){
|
||||||
|
System.out.println(f.getAbsolutePath());
|
||||||
|
makeMiniImage(f.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
//String f="D:\\hahaprj\\tmp\\2023\\07\\30\\840_20230730152314A005.jpg";
|
||||||
|
//makeMiniImage(f);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码文件名
|
* 编码文件名
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
|
||||||
// 过滤请求
|
// 过滤请求
|
||||||
.authorizeRequests()
|
.authorizeRequests()
|
||||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||||
.antMatchers("/login", "/register", "/captchaImage", "/weixin/**","/bgscreen/**","/publics/**").permitAll()
|
.antMatchers("/login", "/register", "/captchaImage", "/weixin/**","/bgscreen/**","/publics/**","/system/dict/data/**").permitAll()
|
||||||
// 静态资源,可匿名访问
|
// 静态资源,可匿名访问
|
||||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/**/img/**", "/profile/**").permitAll()
|
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/**/img/**", "/profile/**").permitAll()
|
||||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||||
|
|
Loading…
Reference in New Issue