修改了七牛云对象存储的功能模块

This commit is contained in:
XinYi Song 2021-12-20 16:26:58 +08:00
parent 411ac03e85
commit cc83b99993
4 changed files with 16 additions and 12 deletions

View File

@ -225,7 +225,7 @@
<dependency> <dependency>
<groupId>com.qiniu</groupId> <groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId> <artifactId>qiniu-java-sdk</artifactId>
<version>[7.2.0, 7.2.99]</version> <version>7.2.11</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>

View File

@ -43,6 +43,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers(HttpMethod.GET,"/api/user/verificationCode").permitAll() .antMatchers(HttpMethod.GET,"/api/user/verificationCode").permitAll()
// 手机号登录 // 手机号登录
.antMatchers(HttpMethod.POST,"/api/user/loginByPhone").permitAll() .antMatchers(HttpMethod.POST,"/api/user/loginByPhone").permitAll()
.antMatchers(HttpMethod.POST,"/qiNiuUploadFile").permitAll()
// 所有其它请求需要身份认证 // 所有其它请求需要身份认证
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()

View File

@ -27,11 +27,17 @@ public class UploadImageServiceImpl implements UploadImageService {
private QiNiuYunConfig qiNiuYunConfig; private QiNiuYunConfig qiNiuYunConfig;
// 七牛文件上传管理器 /**
* 七牛文件上传管理器
*/
private UploadManager uploadManager; private UploadManager uploadManager;
//上传的token /**
* 上传的token
*/
private String token; private String token;
// 七牛认证管理 /**
* 管理
*/
private Auth auth; private Auth auth;
private BucketManager bucketManager; private BucketManager bucketManager;
@ -43,7 +49,7 @@ public class UploadImageServiceImpl implements UploadImageService {
private void init() { private void init() {
// 构造一个带指定Zone对象的配置类, 注意这里的Zone.zone0需要根据主机选择 // 构造一个带指定Zone对象的配置类, 注意这里的Zone.zone0需要根据主机选择
uploadManager = new UploadManager(new Configuration(Zone.zone2())); uploadManager = new UploadManager(new Configuration(Zone.zone1()));
auth = Auth.create(qiNiuYunConfig.getAccessKey(), qiNiuYunConfig.getSecretKey()); auth = Auth.create(qiNiuYunConfig.getAccessKey(), qiNiuYunConfig.getSecretKey());
// 根据命名空间生成的上传token // 根据命名空间生成的上传token
bucketManager = new BucketManager(auth, new Configuration(Zone.zone2())); bucketManager = new BucketManager(auth, new Configuration(Zone.zone2()));
@ -72,7 +78,6 @@ public class UploadImageServiceImpl implements UploadImageService {
} }
// 解析上传成功的结果 // 解析上传成功的结果
DefaultPutRet putRet = new Gson().fromJson(res.bodyString(), DefaultPutRet.class); DefaultPutRet putRet = new Gson().fromJson(res.bodyString(), DefaultPutRet.class);
// 直接返回外链地址 // 直接返回外链地址
return getPrivateFile(imgName); return getPrivateFile(imgName);
} }

View File

@ -90,13 +90,11 @@ my.LoginErrorIntervalTime = 60
#公共密钥 #公共密钥
qiniu.accessKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX qiniu.accessKey=ff2M6nXkD7T7eneAa62eIT3hXHvF4_coarpwgL2F
# 私钥 # 私钥
qiniu.secretKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX qiniu.secretKey=Sk0bJQpQs1iTcqTqaCpypzTgep4g8U1nQbmZx-hh
# 空间名 # 空间名
qiniu.bucket=XXXXXXX qiniu.bucket=business-leyihang
qiniu.zone=XXXXXXX
# 外链默认域名 # 外链默认域名
qiniu.domain=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX qiniu.domain=http://r4el6ttsm.hb-bkt.clouddn.com