From 56efdc44d7e5853c75a1f21d6eecf04fe0f832d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E5=87=A0=E6=B5=B7?= Date: Fri, 16 Oct 2020 23:28:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=B1=E9=85=8D=E7=BD=AE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=9D=A5=E5=88=9D=E5=A7=8B=E5=8C=96=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fileserviceimpl/QiniuFileServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/cn/celess/blog/service/fileserviceimpl/QiniuFileServiceImpl.java b/src/main/java/cn/celess/blog/service/fileserviceimpl/QiniuFileServiceImpl.java index 7352fa1..b3c48f7 100644 --- a/src/main/java/cn/celess/blog/service/fileserviceimpl/QiniuFileServiceImpl.java +++ b/src/main/java/cn/celess/blog/service/fileserviceimpl/QiniuFileServiceImpl.java @@ -1,9 +1,9 @@ package cn.celess.blog.service.fileserviceimpl; +import cn.celess.blog.enmu.ConfigKeyEnum; import cn.celess.blog.entity.model.FileInfo; import cn.celess.blog.entity.model.FileResponse; import cn.celess.blog.service.FileManager; -import com.fasterxml.jackson.databind.ObjectMapper; import com.qiniu.common.QiniuException; import com.qiniu.common.Zone; import com.qiniu.http.Response; @@ -13,7 +13,6 @@ import com.qiniu.storage.UploadManager; import com.qiniu.util.Auth; import com.qiniu.util.StringMap; import lombok.SneakyThrows; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.io.InputStream; @@ -33,14 +32,15 @@ public class QiniuFileServiceImpl implements FileManager { private static BucketManager bucketManager; private static Auth auth; - @Value("${qiniu.accessKey}") - private String accessKey; - @Value("${qiniu.secretKey}") - private String secretKey; - @Value("${qiniu.bucket}") private String bucket; + /** + * todo :: 添加reload 方法 配置修改重新创建对象 + */ private void init() { + String accessKey = System.getProperty(ConfigKeyEnum.FILE_QINIU_ACCESS_KEY.getKey()); + String secretKey = System.getProperty(ConfigKeyEnum.FILE_QINIU_SECRET_KEY.getKey()); + this.bucket = System.getProperty(ConfigKeyEnum.FILE_QINIU_BUCKET.getKey()); if (auth == null || uploadManager == null || bucketManager == null) { auth = Auth.create(accessKey, secretKey); uploadManager = new UploadManager(cfg);