diff --git a/pom.xml b/pom.xml index 98131ad..0e6c7df 100644 --- a/pom.xml +++ b/pom.xml @@ -225,7 +225,7 @@ com.qiniu qiniu-java-sdk - [7.2.0, 7.2.99] + 7.2.11 com.google.code.gson diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 96686fc..4b640ec 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -43,6 +43,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET,"/api/user/verificationCode").permitAll() // 手机号登录 .antMatchers(HttpMethod.POST,"/api/user/loginByPhone").permitAll() + .antMatchers(HttpMethod.POST,"/qiNiuUploadFile").permitAll() // 所有其它请求需要身份认证 .anyRequest().authenticated() .and() diff --git a/src/main/java/com/xkrs/qiniu/service/impl/UploadImageServiceImpl.java b/src/main/java/com/xkrs/qiniu/service/impl/UploadImageServiceImpl.java index 353cfb2..b90ac17 100644 --- a/src/main/java/com/xkrs/qiniu/service/impl/UploadImageServiceImpl.java +++ b/src/main/java/com/xkrs/qiniu/service/impl/UploadImageServiceImpl.java @@ -27,11 +27,17 @@ public class UploadImageServiceImpl implements UploadImageService { private QiNiuYunConfig qiNiuYunConfig; - // 七牛文件上传管理器 + /** + * 七牛文件上传管理器 + */ private UploadManager uploadManager; - //上传的token + /** + * 上传的token + */ private String token; - // 七牛认证管理 + /** + * 管理 + */ private Auth auth; private BucketManager bucketManager; @@ -43,7 +49,7 @@ public class UploadImageServiceImpl implements UploadImageService { private void init() { // 构造一个带指定Zone对象的配置类, 注意这里的Zone.zone0需要根据主机选择 - uploadManager = new UploadManager(new Configuration(Zone.zone2())); + uploadManager = new UploadManager(new Configuration(Zone.zone1())); auth = Auth.create(qiNiuYunConfig.getAccessKey(), qiNiuYunConfig.getSecretKey()); // 根据命名空间生成的上传token 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); - // 直接返回外链地址 return getPrivateFile(imgName); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 25b3cd9..7fae157 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -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.zone=XXXXXXX +qiniu.bucket=business-leyihang # 外链默认域名 -qiniu.domain=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +qiniu.domain=http://r4el6ttsm.hb-bkt.clouddn.com