From cc83b9999357f3d70e8ce06b354dc0c5e601c36c Mon Sep 17 00:00:00 2001
From: XinYi Song <2037158277@qq.com>
Date: Mon, 20 Dec 2021 16:26:58 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=83=E7=89=9B?=
=?UTF-8?q?=E4=BA=91=E5=AF=B9=E8=B1=A1=E5=AD=98=E5=82=A8=E7=9A=84=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
.../com/xkrs/common/config/WebSecurityConfig.java | 1 +
.../service/impl/UploadImageServiceImpl.java | 15 ++++++++++-----
src/main/resources/application.properties | 10 ++++------
4 files changed, 16 insertions(+), 12 deletions(-)
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