mirror of https://github.com/halo-dev/halo
style: change some class name.
parent
ce458d238a
commit
7faa96b45b
|
@ -12,7 +12,7 @@ import org.springframework.util.Assert;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import run.halo.app.exception.FileOperationException;
|
import run.halo.app.exception.FileOperationException;
|
||||||
import run.halo.app.model.enums.AttachmentType;
|
import run.halo.app.model.enums.AttachmentType;
|
||||||
import run.halo.app.model.properties.AliYunProperties;
|
import run.halo.app.model.properties.AliOssProperties;
|
||||||
import run.halo.app.model.support.UploadResult;
|
import run.halo.app.model.support.UploadResult;
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.utils.FilenameUtils;
|
import run.halo.app.utils.FilenameUtils;
|
||||||
|
@ -30,11 +30,11 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class AliYunFileHandler implements FileHandler {
|
public class AliOssFileHandler implements FileHandler {
|
||||||
|
|
||||||
private final OptionService optionService;
|
private final OptionService optionService;
|
||||||
|
|
||||||
public AliYunFileHandler(OptionService optionService) {
|
public AliOssFileHandler(OptionService optionService) {
|
||||||
this.optionService = optionService;
|
this.optionService = optionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,15 +43,15 @@ public class AliYunFileHandler implements FileHandler {
|
||||||
Assert.notNull(file, "Multipart file must not be null");
|
Assert.notNull(file, "Multipart file must not be null");
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
String protocol = optionService.getByPropertyOfNonNull(AliYunProperties.OSS_PROTOCOL).toString();
|
String protocol = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_PROTOCOL).toString();
|
||||||
String domain = optionService.getByPropertyOrDefault(AliYunProperties.OSS_DOMAIN, String.class, "");
|
String domain = optionService.getByPropertyOrDefault(AliOssProperties.OSS_DOMAIN, String.class, "");
|
||||||
String endPoint = optionService.getByPropertyOfNonNull(AliYunProperties.OSS_ENDPOINT).toString();
|
String endPoint = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_ENDPOINT).toString();
|
||||||
String accessKey = optionService.getByPropertyOfNonNull(AliYunProperties.OSS_ACCESS_KEY).toString();
|
String accessKey = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_ACCESS_KEY).toString();
|
||||||
String accessSecret = optionService.getByPropertyOfNonNull(AliYunProperties.OSS_ACCESS_SECRET).toString();
|
String accessSecret = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_ACCESS_SECRET).toString();
|
||||||
String bucketName = optionService.getByPropertyOfNonNull(AliYunProperties.OSS_BUCKET_NAME).toString();
|
String bucketName = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_BUCKET_NAME).toString();
|
||||||
String source = StringUtils.join(protocol, bucketName, "." + endPoint);
|
String source = StringUtils.join(protocol, bucketName, "." + endPoint);
|
||||||
String styleRule = optionService.getByPropertyOrDefault(AliYunProperties.OSS_STYLE_RULE, String.class, "");
|
String styleRule = optionService.getByPropertyOrDefault(AliOssProperties.OSS_STYLE_RULE, String.class, "");
|
||||||
String thumbnailStyleRule = optionService.getByPropertyOrDefault(AliYunProperties.OSS_THUMBNAIL_STYLE_RULE, String.class, "");
|
String thumbnailStyleRule = optionService.getByPropertyOrDefault(AliOssProperties.OSS_THUMBNAIL_STYLE_RULE, String.class, "");
|
||||||
|
|
||||||
// Init OSS client
|
// Init OSS client
|
||||||
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKey, accessSecret);
|
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKey, accessSecret);
|
||||||
|
@ -108,10 +108,10 @@ public class AliYunFileHandler implements FileHandler {
|
||||||
Assert.notNull(key, "File key must not be blank");
|
Assert.notNull(key, "File key must not be blank");
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
String endPoint = optionService.getByPropertyOfNonNull(AliYunProperties.OSS_ENDPOINT).toString();
|
String endPoint = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_ENDPOINT).toString();
|
||||||
String accessKey = optionService.getByPropertyOfNonNull(AliYunProperties.OSS_ACCESS_KEY).toString();
|
String accessKey = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_ACCESS_KEY).toString();
|
||||||
String accessSecret = optionService.getByPropertyOfNonNull(AliYunProperties.OSS_ACCESS_SECRET).toString();
|
String accessSecret = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_ACCESS_SECRET).toString();
|
||||||
String bucketName = optionService.getByPropertyOfNonNull(AliYunProperties.OSS_BUCKET_NAME).toString();
|
String bucketName = optionService.getByPropertyOfNonNull(AliOssProperties.OSS_BUCKET_NAME).toString();
|
||||||
|
|
||||||
// Init OSS client
|
// Init OSS client
|
||||||
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKey, accessSecret);
|
OSS ossClient = new OSSClientBuilder().build(endPoint, accessKey, accessSecret);
|
|
@ -13,7 +13,7 @@ import org.springframework.util.Assert;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import run.halo.app.exception.FileOperationException;
|
import run.halo.app.exception.FileOperationException;
|
||||||
import run.halo.app.model.enums.AttachmentType;
|
import run.halo.app.model.enums.AttachmentType;
|
||||||
import run.halo.app.model.properties.BaiDuYunProperties;
|
import run.halo.app.model.properties.BaiduBosProperties;
|
||||||
import run.halo.app.model.support.UploadResult;
|
import run.halo.app.model.support.UploadResult;
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.utils.FilenameUtils;
|
import run.halo.app.utils.FilenameUtils;
|
||||||
|
@ -31,11 +31,11 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class BaiDuYunFileHandler implements FileHandler {
|
public class BaiduBosFileHandler implements FileHandler {
|
||||||
|
|
||||||
private final OptionService optionService;
|
private final OptionService optionService;
|
||||||
|
|
||||||
public BaiDuYunFileHandler(OptionService optionService) {
|
public BaiduBosFileHandler(OptionService optionService) {
|
||||||
this.optionService = optionService;
|
this.optionService = optionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,14 +44,14 @@ public class BaiDuYunFileHandler implements FileHandler {
|
||||||
Assert.notNull(file, "Multipart file must not be null");
|
Assert.notNull(file, "Multipart file must not be null");
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
Object protocol = optionService.getByPropertyOfNonNull(BaiDuYunProperties.BOS_PROTOCOL);
|
Object protocol = optionService.getByPropertyOfNonNull(BaiduBosProperties.BOS_PROTOCOL);
|
||||||
String domain = optionService.getByPropertyOrDefault(BaiDuYunProperties.BOS_DOMAIN, String.class, "");
|
String domain = optionService.getByPropertyOrDefault(BaiduBosProperties.BOS_DOMAIN, String.class, "");
|
||||||
String endPoint = optionService.getByPropertyOfNonNull(BaiDuYunProperties.BOS_ENDPOINT).toString();
|
String endPoint = optionService.getByPropertyOfNonNull(BaiduBosProperties.BOS_ENDPOINT).toString();
|
||||||
String accessKey = optionService.getByPropertyOfNonNull(BaiDuYunProperties.BOS_ACCESS_KEY).toString();
|
String accessKey = optionService.getByPropertyOfNonNull(BaiduBosProperties.BOS_ACCESS_KEY).toString();
|
||||||
String secretKey = optionService.getByPropertyOfNonNull(BaiDuYunProperties.BOS_SECRET_KEY).toString();
|
String secretKey = optionService.getByPropertyOfNonNull(BaiduBosProperties.BOS_SECRET_KEY).toString();
|
||||||
String bucketName = optionService.getByPropertyOfNonNull(BaiDuYunProperties.BOS_BUCKET_NAME).toString();
|
String bucketName = optionService.getByPropertyOfNonNull(BaiduBosProperties.BOS_BUCKET_NAME).toString();
|
||||||
String styleRule = optionService.getByPropertyOrDefault(BaiDuYunProperties.BOS_STYLE_RULE, String.class, "");
|
String styleRule = optionService.getByPropertyOrDefault(BaiduBosProperties.BOS_STYLE_RULE, String.class, "");
|
||||||
String thumbnailStyleRule = optionService.getByPropertyOrDefault(BaiDuYunProperties.BOS_THUMBNAIL_STYLE_RULE, String.class, "");
|
String thumbnailStyleRule = optionService.getByPropertyOrDefault(BaiduBosProperties.BOS_THUMBNAIL_STYLE_RULE, String.class, "");
|
||||||
String source = StringUtils.join(protocol, bucketName, "." + endPoint);
|
String source = StringUtils.join(protocol, bucketName, "." + endPoint);
|
||||||
|
|
||||||
BosClientConfiguration config = new BosClientConfiguration();
|
BosClientConfiguration config = new BosClientConfiguration();
|
||||||
|
@ -106,10 +106,10 @@ public class BaiDuYunFileHandler implements FileHandler {
|
||||||
Assert.notNull(key, "File key must not be blank");
|
Assert.notNull(key, "File key must not be blank");
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
String endPoint = optionService.getByPropertyOfNonNull(BaiDuYunProperties.BOS_ENDPOINT).toString();
|
String endPoint = optionService.getByPropertyOfNonNull(BaiduBosProperties.BOS_ENDPOINT).toString();
|
||||||
String accessKey = optionService.getByPropertyOfNonNull(BaiDuYunProperties.BOS_ACCESS_KEY).toString();
|
String accessKey = optionService.getByPropertyOfNonNull(BaiduBosProperties.BOS_ACCESS_KEY).toString();
|
||||||
String secretKey = optionService.getByPropertyOfNonNull(BaiDuYunProperties.BOS_SECRET_KEY).toString();
|
String secretKey = optionService.getByPropertyOfNonNull(BaiduBosProperties.BOS_SECRET_KEY).toString();
|
||||||
String bucketName = optionService.getByPropertyOfNonNull(BaiDuYunProperties.BOS_BUCKET_NAME).toString();
|
String bucketName = optionService.getByPropertyOfNonNull(BaiduBosProperties.BOS_BUCKET_NAME).toString();
|
||||||
|
|
||||||
BosClientConfiguration config = new BosClientConfiguration();
|
BosClientConfiguration config = new BosClientConfiguration();
|
||||||
config.setCredentials(new DefaultBceCredentials(accessKey, secretKey));
|
config.setCredentials(new DefaultBceCredentials(accessKey, secretKey));
|
|
@ -17,7 +17,7 @@ import org.springframework.util.Assert;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import run.halo.app.exception.FileOperationException;
|
import run.halo.app.exception.FileOperationException;
|
||||||
import run.halo.app.model.enums.AttachmentType;
|
import run.halo.app.model.enums.AttachmentType;
|
||||||
import run.halo.app.model.properties.QnYunProperties;
|
import run.halo.app.model.properties.QiniuOssProperties;
|
||||||
import run.halo.app.model.support.QiNiuPutSet;
|
import run.halo.app.model.support.QiNiuPutSet;
|
||||||
import run.halo.app.model.support.UploadResult;
|
import run.halo.app.model.support.UploadResult;
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
|
@ -40,11 +40,11 @@ import static run.halo.app.handler.file.FileHandler.isImageType;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class QnYunFileHandler implements FileHandler {
|
public class QiniuOssFileHandler implements FileHandler {
|
||||||
|
|
||||||
private final OptionService optionService;
|
private final OptionService optionService;
|
||||||
|
|
||||||
public QnYunFileHandler(OptionService optionService) {
|
public QiniuOssFileHandler(OptionService optionService) {
|
||||||
this.optionService = optionService;
|
this.optionService = optionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,13 +54,13 @@ public class QnYunFileHandler implements FileHandler {
|
||||||
|
|
||||||
// Get all config
|
// Get all config
|
||||||
Zone zone = optionService.getQnYunZone();
|
Zone zone = optionService.getQnYunZone();
|
||||||
String accessKey = optionService.getByPropertyOfNonNull(QnYunProperties.OSS_ACCESS_KEY).toString();
|
String accessKey = optionService.getByPropertyOfNonNull(QiniuOssProperties.OSS_ACCESS_KEY).toString();
|
||||||
String secretKey = optionService.getByPropertyOfNonNull(QnYunProperties.OSS_SECRET_KEY).toString();
|
String secretKey = optionService.getByPropertyOfNonNull(QiniuOssProperties.OSS_SECRET_KEY).toString();
|
||||||
String bucket = optionService.getByPropertyOfNonNull(QnYunProperties.OSS_BUCKET).toString();
|
String bucket = optionService.getByPropertyOfNonNull(QiniuOssProperties.OSS_BUCKET).toString();
|
||||||
String protocol = optionService.getByPropertyOfNonNull(QnYunProperties.OSS_PROTOCOL).toString();
|
String protocol = optionService.getByPropertyOfNonNull(QiniuOssProperties.OSS_PROTOCOL).toString();
|
||||||
String domain = optionService.getByPropertyOfNonNull(QnYunProperties.OSS_DOMAIN).toString();
|
String domain = optionService.getByPropertyOfNonNull(QiniuOssProperties.OSS_DOMAIN).toString();
|
||||||
String styleRule = optionService.getByPropertyOrDefault(QnYunProperties.OSS_STYLE_RULE, String.class, "");
|
String styleRule = optionService.getByPropertyOrDefault(QiniuOssProperties.OSS_STYLE_RULE, String.class, "");
|
||||||
String thumbnailStyleRule = optionService.getByPropertyOrDefault(QnYunProperties.OSS_THUMBNAIL_STYLE_RULE, String.class, "");
|
String thumbnailStyleRule = optionService.getByPropertyOrDefault(QiniuOssProperties.OSS_THUMBNAIL_STYLE_RULE, String.class, "");
|
||||||
|
|
||||||
// Create configuration
|
// Create configuration
|
||||||
Configuration configuration = new Configuration(zone);
|
Configuration configuration = new Configuration(zone);
|
||||||
|
@ -133,9 +133,9 @@ public class QnYunFileHandler implements FileHandler {
|
||||||
|
|
||||||
// Get all config
|
// Get all config
|
||||||
Zone zone = optionService.getQnYunZone();
|
Zone zone = optionService.getQnYunZone();
|
||||||
String accessKey = optionService.getByPropertyOfNonNull(QnYunProperties.OSS_ACCESS_KEY).toString();
|
String accessKey = optionService.getByPropertyOfNonNull(QiniuOssProperties.OSS_ACCESS_KEY).toString();
|
||||||
String secretKey = optionService.getByPropertyOfNonNull(QnYunProperties.OSS_SECRET_KEY).toString();
|
String secretKey = optionService.getByPropertyOfNonNull(QiniuOssProperties.OSS_SECRET_KEY).toString();
|
||||||
String bucket = optionService.getByPropertyOfNonNull(QnYunProperties.OSS_BUCKET).toString();
|
String bucket = optionService.getByPropertyOfNonNull(QiniuOssProperties.OSS_BUCKET).toString();
|
||||||
|
|
||||||
// Create configuration
|
// Create configuration
|
||||||
Configuration configuration = new Configuration(zone);
|
Configuration configuration = new Configuration(zone);
|
|
@ -16,7 +16,7 @@ import org.springframework.util.Assert;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import run.halo.app.exception.FileOperationException;
|
import run.halo.app.exception.FileOperationException;
|
||||||
import run.halo.app.model.enums.AttachmentType;
|
import run.halo.app.model.enums.AttachmentType;
|
||||||
import run.halo.app.model.properties.TencentYunProperties;
|
import run.halo.app.model.properties.TencentCosProperties;
|
||||||
import run.halo.app.model.support.UploadResult;
|
import run.halo.app.model.support.UploadResult;
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.utils.FilenameUtils;
|
import run.halo.app.utils.FilenameUtils;
|
||||||
|
@ -34,11 +34,11 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class TencentYunFileHandler implements FileHandler {
|
public class TencentCosFileHandler implements FileHandler {
|
||||||
|
|
||||||
private final OptionService optionService;
|
private final OptionService optionService;
|
||||||
|
|
||||||
public TencentYunFileHandler(OptionService optionService) {
|
public TencentCosFileHandler(OptionService optionService) {
|
||||||
this.optionService = optionService;
|
this.optionService = optionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,15 +47,15 @@ public class TencentYunFileHandler implements FileHandler {
|
||||||
Assert.notNull(file, "Multipart file must not be null");
|
Assert.notNull(file, "Multipart file must not be null");
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
String protocol = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_PROTOCOL).toString();
|
String protocol = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_PROTOCOL).toString();
|
||||||
String domain = optionService.getByPropertyOrDefault(TencentYunProperties.COS_DOMAIN, String.class, "");
|
String domain = optionService.getByPropertyOrDefault(TencentCosProperties.COS_DOMAIN, String.class, "");
|
||||||
String region = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_REGION).toString();
|
String region = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_REGION).toString();
|
||||||
String secretId = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_SECRET_ID).toString();
|
String secretId = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_SECRET_ID).toString();
|
||||||
String secretKey = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_SECRET_KEY).toString();
|
String secretKey = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_SECRET_KEY).toString();
|
||||||
String bucketName = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_BUCKET_NAME).toString();
|
String bucketName = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_BUCKET_NAME).toString();
|
||||||
String source = StringUtils.join(protocol, bucketName, ".cos." + region + ".myqcloud.com");
|
String source = StringUtils.join(protocol, bucketName, ".cos." + region + ".myqcloud.com");
|
||||||
String styleRule = optionService.getByPropertyOrDefault(TencentYunProperties.COS_STYLE_RULE, String.class, "");
|
String styleRule = optionService.getByPropertyOrDefault(TencentCosProperties.COS_STYLE_RULE, String.class, "");
|
||||||
String thumbnailStyleRule = optionService.getByPropertyOrDefault(TencentYunProperties.COS_THUMBNAIL_STYLE_RULE, String.class, "");
|
String thumbnailStyleRule = optionService.getByPropertyOrDefault(TencentCosProperties.COS_THUMBNAIL_STYLE_RULE, String.class, "");
|
||||||
|
|
||||||
//get file attribute
|
//get file attribute
|
||||||
long size = file.getSize();
|
long size = file.getSize();
|
||||||
|
@ -119,10 +119,10 @@ public class TencentYunFileHandler implements FileHandler {
|
||||||
Assert.notNull(key, "File key must not be blank");
|
Assert.notNull(key, "File key must not be blank");
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
String region = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_REGION).toString();
|
String region = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_REGION).toString();
|
||||||
String secretId = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_SECRET_ID).toString();
|
String secretId = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_SECRET_ID).toString();
|
||||||
String secretKey = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_SECRET_KEY).toString();
|
String secretKey = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_SECRET_KEY).toString();
|
||||||
String bucketName = optionService.getByPropertyOfNonNull(TencentYunProperties.COS_BUCKET_NAME).toString();
|
String bucketName = optionService.getByPropertyOfNonNull(TencentCosProperties.COS_BUCKET_NAME).toString();
|
||||||
|
|
||||||
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
|
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
|
||||||
Region regionConfig = new Region(region);
|
Region regionConfig = new Region(region);
|
|
@ -10,7 +10,7 @@ import org.springframework.util.DigestUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import run.halo.app.exception.FileOperationException;
|
import run.halo.app.exception.FileOperationException;
|
||||||
import run.halo.app.model.enums.AttachmentType;
|
import run.halo.app.model.enums.AttachmentType;
|
||||||
import run.halo.app.model.properties.UpYunProperties;
|
import run.halo.app.model.properties.UpOssProperties;
|
||||||
import run.halo.app.model.support.UploadResult;
|
import run.halo.app.model.support.UploadResult;
|
||||||
import run.halo.app.service.OptionService;
|
import run.halo.app.service.OptionService;
|
||||||
import run.halo.app.utils.FilenameUtils;
|
import run.halo.app.utils.FilenameUtils;
|
||||||
|
@ -28,11 +28,11 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class UpYunFileHandler implements FileHandler {
|
public class UpOssFileHandler implements FileHandler {
|
||||||
|
|
||||||
private final OptionService optionService;
|
private final OptionService optionService;
|
||||||
|
|
||||||
public UpYunFileHandler(OptionService optionService) {
|
public UpOssFileHandler(OptionService optionService) {
|
||||||
this.optionService = optionService;
|
this.optionService = optionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,15 +40,15 @@ public class UpYunFileHandler implements FileHandler {
|
||||||
public UploadResult upload(MultipartFile file) {
|
public UploadResult upload(MultipartFile file) {
|
||||||
Assert.notNull(file, "Multipart file must not be null");
|
Assert.notNull(file, "Multipart file must not be null");
|
||||||
|
|
||||||
String source = optionService.getByPropertyOfNonNull(UpYunProperties.OSS_SOURCE).toString();
|
String source = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_SOURCE).toString();
|
||||||
String password = optionService.getByPropertyOfNonNull(UpYunProperties.OSS_PASSWORD).toString();
|
String password = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_PASSWORD).toString();
|
||||||
String bucket = optionService.getByPropertyOfNonNull(UpYunProperties.OSS_BUCKET).toString();
|
String bucket = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_BUCKET).toString();
|
||||||
String protocol = optionService.getByPropertyOfNonNull(UpYunProperties.OSS_PROTOCOL).toString();
|
String protocol = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_PROTOCOL).toString();
|
||||||
String domain = optionService.getByPropertyOfNonNull(UpYunProperties.OSS_DOMAIN).toString();
|
String domain = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_DOMAIN).toString();
|
||||||
String operator = optionService.getByPropertyOfNonNull(UpYunProperties.OSS_OPERATOR).toString();
|
String operator = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_OPERATOR).toString();
|
||||||
// style rule can be null
|
// style rule can be null
|
||||||
String styleRule = optionService.getByPropertyOrDefault(UpYunProperties.OSS_STYLE_RULE, String.class, "");
|
String styleRule = optionService.getByPropertyOrDefault(UpOssProperties.OSS_STYLE_RULE, String.class, "");
|
||||||
String thumbnailStyleRule = optionService.getByPropertyOrDefault(UpYunProperties.OSS_THUMBNAIL_STYLE_RULE, String.class, "");
|
String thumbnailStyleRule = optionService.getByPropertyOrDefault(UpOssProperties.OSS_THUMBNAIL_STYLE_RULE, String.class, "");
|
||||||
|
|
||||||
// Create up yun
|
// Create up yun
|
||||||
UpYun upYun = new UpYun(bucket, operator, password);
|
UpYun upYun = new UpYun(bucket, operator, password);
|
||||||
|
@ -103,9 +103,9 @@ public class UpYunFileHandler implements FileHandler {
|
||||||
Assert.notNull(key, "File key must not be blank");
|
Assert.notNull(key, "File key must not be blank");
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
String password = optionService.getByPropertyOfNonNull(UpYunProperties.OSS_PASSWORD).toString();
|
String password = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_PASSWORD).toString();
|
||||||
String bucket = optionService.getByPropertyOfNonNull(UpYunProperties.OSS_BUCKET).toString();
|
String bucket = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_BUCKET).toString();
|
||||||
String operator = optionService.getByPropertyOfNonNull(UpYunProperties.OSS_OPERATOR).toString();
|
String operator = optionService.getByPropertyOfNonNull(UpOssProperties.OSS_OPERATOR).toString();
|
||||||
|
|
||||||
// Create up yun
|
// Create up yun
|
||||||
UpYun upYun = new UpYun(bucket, operator, password);
|
UpYun upYun = new UpYun(bucket, operator, password);
|
|
@ -7,7 +7,7 @@ package run.halo.app.model.properties;
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 2019-04-04
|
* @date 2019-04-04
|
||||||
*/
|
*/
|
||||||
public enum AliYunProperties implements PropertyEnum {
|
public enum AliOssProperties implements PropertyEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aliyun oss domain protocol
|
* Aliyun oss domain protocol
|
||||||
|
@ -55,7 +55,7 @@ public enum AliYunProperties implements PropertyEnum {
|
||||||
|
|
||||||
private final String defaultValue;
|
private final String defaultValue;
|
||||||
|
|
||||||
AliYunProperties(String value, Class<?> type, String defaultValue) {
|
AliOssProperties(String value, Class<?> type, String defaultValue) {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
if (!PropertyEnum.isSupportedType(type)) {
|
if (!PropertyEnum.isSupportedType(type)) {
|
||||||
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
|
@ -7,7 +7,7 @@ package run.halo.app.model.properties;
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 2019-07-19
|
* @date 2019-07-19
|
||||||
*/
|
*/
|
||||||
public enum BaiDuYunProperties implements PropertyEnum {
|
public enum BaiduBosProperties implements PropertyEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Baidu yun bos domain protocol.
|
* Baidu yun bos domain protocol.
|
||||||
|
@ -55,7 +55,7 @@ public enum BaiDuYunProperties implements PropertyEnum {
|
||||||
|
|
||||||
private final String defaultValue;
|
private final String defaultValue;
|
||||||
|
|
||||||
BaiDuYunProperties(String value, Class<?> type, String defaultValue) {
|
BaiduBosProperties(String value, Class<?> type, String defaultValue) {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
if (!PropertyEnum.isSupportedType(type)) {
|
if (!PropertyEnum.isSupportedType(type)) {
|
||||||
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
|
@ -143,7 +143,7 @@ public interface PropertyEnum extends ValueEnum<String> {
|
||||||
static Map<String, PropertyEnum> getValuePropertyEnumMap() {
|
static Map<String, PropertyEnum> getValuePropertyEnumMap() {
|
||||||
// Get all properties
|
// Get all properties
|
||||||
List<Class<? extends PropertyEnum>> propertyEnumClasses = new LinkedList<>();
|
List<Class<? extends PropertyEnum>> propertyEnumClasses = new LinkedList<>();
|
||||||
propertyEnumClasses.add(AliYunProperties.class);
|
propertyEnumClasses.add(AliOssProperties.class);
|
||||||
propertyEnumClasses.add(AttachmentProperties.class);
|
propertyEnumClasses.add(AttachmentProperties.class);
|
||||||
propertyEnumClasses.add(BlogProperties.class);
|
propertyEnumClasses.add(BlogProperties.class);
|
||||||
propertyEnumClasses.add(CommentProperties.class);
|
propertyEnumClasses.add(CommentProperties.class);
|
||||||
|
@ -151,9 +151,9 @@ public interface PropertyEnum extends ValueEnum<String> {
|
||||||
propertyEnumClasses.add(OtherProperties.class);
|
propertyEnumClasses.add(OtherProperties.class);
|
||||||
propertyEnumClasses.add(PostProperties.class);
|
propertyEnumClasses.add(PostProperties.class);
|
||||||
propertyEnumClasses.add(PrimaryProperties.class);
|
propertyEnumClasses.add(PrimaryProperties.class);
|
||||||
propertyEnumClasses.add(QnYunProperties.class);
|
propertyEnumClasses.add(QiniuOssProperties.class);
|
||||||
propertyEnumClasses.add(SeoProperties.class);
|
propertyEnumClasses.add(SeoProperties.class);
|
||||||
propertyEnumClasses.add(UpYunProperties.class);
|
propertyEnumClasses.add(UpOssProperties.class);
|
||||||
propertyEnumClasses.add(ApiProperties.class);
|
propertyEnumClasses.add(ApiProperties.class);
|
||||||
|
|
||||||
Map<String, PropertyEnum> result = new HashMap<>();
|
Map<String, PropertyEnum> result = new HashMap<>();
|
||||||
|
|
|
@ -7,7 +7,7 @@ package run.halo.app.model.properties;
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 2019-03-26
|
* @date 2019-03-26
|
||||||
*/
|
*/
|
||||||
public enum QnYunProperties implements PropertyEnum {
|
public enum QiniuOssProperties implements PropertyEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Qiniu yun oss zone.
|
* Qiniu yun oss zone.
|
||||||
|
@ -55,7 +55,7 @@ public enum QnYunProperties implements PropertyEnum {
|
||||||
|
|
||||||
private final String defaultValue;
|
private final String defaultValue;
|
||||||
|
|
||||||
QnYunProperties(String value, Class<?> type, String defaultValue) {
|
QiniuOssProperties(String value, Class<?> type, String defaultValue) {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
if (!PropertyEnum.isSupportedType(type)) {
|
if (!PropertyEnum.isSupportedType(type)) {
|
||||||
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
|
@ -7,7 +7,7 @@ package run.halo.app.model.properties;
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 2019-07-25
|
* @date 2019-07-25
|
||||||
*/
|
*/
|
||||||
public enum TencentYunProperties implements PropertyEnum {
|
public enum TencentCosProperties implements PropertyEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tencent yun cos domain protocol.
|
* Tencent yun cos domain protocol.
|
||||||
|
@ -55,7 +55,7 @@ public enum TencentYunProperties implements PropertyEnum {
|
||||||
|
|
||||||
private final String defaultValue;
|
private final String defaultValue;
|
||||||
|
|
||||||
TencentYunProperties(String value, Class<?> type, String defaultValue) {
|
TencentCosProperties(String value, Class<?> type, String defaultValue) {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
if (!PropertyEnum.isSupportedType(type)) {
|
if (!PropertyEnum.isSupportedType(type)) {
|
||||||
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
|
@ -7,7 +7,7 @@ package run.halo.app.model.properties;
|
||||||
* @author ryanwang
|
* @author ryanwang
|
||||||
* @date 2019-03-27
|
* @date 2019-03-27
|
||||||
*/
|
*/
|
||||||
public enum UpYunProperties implements PropertyEnum {
|
public enum UpOssProperties implements PropertyEnum {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* upyun oss source
|
* upyun oss source
|
||||||
|
@ -53,7 +53,7 @@ public enum UpYunProperties implements PropertyEnum {
|
||||||
private String value;
|
private String value;
|
||||||
private Class<?> type;
|
private Class<?> type;
|
||||||
|
|
||||||
UpYunProperties(String value, Class<?> type, String defaultValue) {
|
UpOssProperties(String value, Class<?> type, String defaultValue) {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
if (!PropertyEnum.isSupportedType(type)) {
|
if (!PropertyEnum.isSupportedType(type)) {
|
||||||
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
throw new IllegalArgumentException("Unsupported blog property type: " + type);
|
|
@ -324,7 +324,7 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Zone getQnYunZone() {
|
public Zone getQnYunZone() {
|
||||||
return getByProperty(QnYunProperties.OSS_ZONE).map(qiniuZone -> {
|
return getByProperty(QiniuOssProperties.OSS_ZONE).map(qiniuZone -> {
|
||||||
|
|
||||||
Zone zone;
|
Zone zone;
|
||||||
switch (qiniuZone.toString()) {
|
switch (qiniuZone.toString()) {
|
||||||
|
|
Loading…
Reference in New Issue