mirror of https://github.com/halo-dev/halo
feat: support set style rule for tencent cos.
parent
6ce444171b
commit
dc497c3c85
|
@ -54,6 +54,8 @@ public class TencentYunFileHandler implements FileHandler {
|
|||
String secretKey = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_SECRET_KEY).toString();
|
||||
String bucketName = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_BUCKET_NAME).toString();
|
||||
String source = StringUtils.join(protocol, bucketName, ".cos." + region + ".myqcloud.com");
|
||||
String styleRule = optionService.getByPropertyOrDefault(TencentYunProperties.COS_STYLE_RULE, String.class, "");
|
||||
String thumbnailStyleRule = optionService.getByPropertyOrDefault(TencentYunProperties.COS_THUMBNAIL_STYLE_RULE, String.class, "");
|
||||
|
||||
//get file attribute
|
||||
long size = file.getSize();
|
||||
|
@ -90,7 +92,7 @@ public class TencentYunFileHandler implements FileHandler {
|
|||
// Response result
|
||||
UploadResult uploadResult = new UploadResult();
|
||||
uploadResult.setFilename(basename);
|
||||
uploadResult.setFilePath(filePath);
|
||||
uploadResult.setFilePath(StringUtils.isBlank(styleRule) ? filePath : filePath + styleRule);
|
||||
uploadResult.setKey(upFilePath);
|
||||
uploadResult.setMediaType(MediaType.valueOf(Objects.requireNonNull(file.getContentType())));
|
||||
uploadResult.setSuffix(extension);
|
||||
|
@ -101,7 +103,7 @@ public class TencentYunFileHandler implements FileHandler {
|
|||
BufferedImage image = ImageIO.read(file.getInputStream());
|
||||
uploadResult.setWidth(image.getWidth());
|
||||
uploadResult.setHeight(image.getHeight());
|
||||
uploadResult.setThumbPath(filePath);
|
||||
uploadResult.setThumbPath(StringUtils.isBlank(thumbnailStyleRule) ? filePath : filePath + thumbnailStyleRule);
|
||||
}
|
||||
|
||||
return uploadResult;
|
||||
|
|
|
@ -54,8 +54,9 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
|||
log.info("Halo started at {}", blogUrl);
|
||||
log.info("Halo admin started at {}{}", blogUrl, haloProperties.getAdminPath());
|
||||
if (!haloProperties.isDocDisabled()) {
|
||||
log.debug("Halo doc was enable at {}/swagger-ui.html", blogUrl);
|
||||
log.debug("Halo api doc was enabled at {}/swagger-ui.html", blogUrl);
|
||||
}
|
||||
log.info("Halo has started successfully!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,12 +40,12 @@ public enum AliYunProperties implements PropertyEnum {
|
|||
OSS_ACCESS_SECRET("oss_aliyun_access_secret", String.class, ""),
|
||||
|
||||
/**
|
||||
* Aliyun oss style rule
|
||||
* Aliyun oss style rule.
|
||||
*/
|
||||
OSS_STYLE_RULE("oss_aliyun_style_rule", String.class, ""),
|
||||
|
||||
/**
|
||||
* Aliyun oss thumbnail style rule
|
||||
* Aliyun oss thumbnail style rule.
|
||||
*/
|
||||
OSS_THUMBNAIL_STYLE_RULE("oss_aliyun_thumbnail_style_rule", String.class, "");
|
||||
|
||||
|
|
|
@ -37,7 +37,17 @@ public enum TencentYunProperties implements PropertyEnum {
|
|||
/**
|
||||
* Tencent yun cos secret key.
|
||||
*/
|
||||
COS_SECRET_KEY("cos_tencentyun_secret_key", String.class, "");
|
||||
COS_SECRET_KEY("cos_tencentyun_secret_key", String.class, ""),
|
||||
|
||||
/**
|
||||
* Tencent yun cos style rule.
|
||||
*/
|
||||
COS_STYLE_RULE("cos_tencentyun_style_rule", String.class, ""),
|
||||
|
||||
/**
|
||||
* Tencent yun cos thumbnail style rule.
|
||||
*/
|
||||
COS_THUMBNAIL_STYLE_RULE("cos_tencentyun_thumbnail_style_rule", String.class, "");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
|
Loading…
Reference in New Issue