获取资源前缀是否为https

1.给缓存增加过期时间,并且和第三方存储资源 过期时间保持一致
pull/61/head
刘小不狼狈 2024-03-15 17:16:02 +08:00 committed by stylefeng
parent f372c0c143
commit b6a01c485f
3 changed files with 13 additions and 7 deletions

View File

@ -52,4 +52,9 @@ public class AliyunOssProperties {
*/
private String accessKeySecret;
/**
* https
*/
private Boolean isHttps = false;
}

View File

@ -32,10 +32,8 @@ import cn.stylefeng.roses.kernel.file.api.exception.FileException;
import cn.stylefeng.roses.kernel.file.api.exception.enums.FileExceptionEnum;
import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander;
import cn.stylefeng.roses.kernel.file.api.pojo.props.AliyunOssProperties;
import com.aliyun.oss.ClientException;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.OSSException;
import com.aliyun.oss.*;
import com.aliyun.oss.common.comm.Protocol;
import com.aliyun.oss.model.CannedAccessControlList;
import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.PutObjectRequest;
@ -73,9 +71,11 @@ public class AliyunFileOperator implements FileOperatorApi {
String endpoint = aliyunOssProperties.getEndPoint();
String accessKeyId = aliyunOssProperties.getAccessKeyId();
String accessKeySecret = aliyunOssProperties.getAccessKeySecret();
Boolean isHttps = aliyunOssProperties.getIsHttps();
ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
clientBuilderConfiguration.setProtocol(isHttps ? Protocol.HTTPS : Protocol.HTTP);
// 创建OSSClient实例。
ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret, clientBuilderConfiguration);
}
@Override

View File

@ -10,6 +10,7 @@ import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.file.api.FileInfoApi;
import cn.stylefeng.roses.kernel.file.api.expander.FileConfigExpander;
import cn.stylefeng.roses.kernel.file.api.pojo.AntdvFileInfo;
import cn.stylefeng.roses.kernel.file.api.pojo.request.SysFileInfoRequest;
import cn.stylefeng.roses.kernel.rule.callback.ConfigUpdateCallback;
@ -247,7 +248,7 @@ public class SysThemeServiceImpl extends ServiceImpl<SysThemeMapper, SysTheme> i
this.parseFileUrls(result);
// 缓存系统中激活的主题
themeCacheApi.put(ThemeConstants.THEME_GUNS_PLATFORM, result);
themeCacheApi.put(ThemeConstants.THEME_GUNS_PLATFORM, result, FileConfigExpander.getDefaultFileTimeoutSeconds());
return result;
}