com.github.javaclub.ossclient.OssConstants Maven / Gradle / Ivy
package com.github.javaclub.ossclient;
import com.github.javaclub.toolbox.ToolBox.Environments;
import com.github.javaclub.toolbox.ToolBox.Strings;
import com.github.javaclub.toolbox.conf.CompositeAppConfigProperties;
public interface OssConstants {
public static final String OSS_DEFAULT_PROVIDER = "system.configs.oss.default-provider";
public static final String SAME_ORIGIN_CHECK = "system.configs.oss.same-origin-referer-check";
public static final String FILE_UPLOAD_LIMIT_SIZE = "system.configs.oss.file-upload-limit-mb-size";
public static final String FILE_ARCHIVED_BY_DATE = "system.configs.oss.file-archived-by-date";
public static final String ALLOWED_FILES = "system.configs.oss.allowed-files";
public static final String FILE_FORMAT_PARAM_KEY = "fileFormatLimits";
public static final String BUCKET_NAME_PARAM_KEY = "bucket";
public static final String CONTENT_TYPE_PARAM_KEY = "contentType";
public static final String EXTRA_BIZ_KEY_PARAM = "key";
public static class Aliyun {
public static final String ENDPOINT = "system.configs.oss.aliyun.endpoint";
public static final String ACCESS_KEY = "system.configs.oss.aliyun.access-key";
public static final String SECRET_KEY = "system.configs.oss.aliyun.secret-key";
public static final String CDN_DOMAIN = "system.configs.oss.aliyun.cdn-domain";
public static final String CDN_PROTOCOL = "system.configs.oss.aliyun.cdn-protocol";
public static final String DEFAULT_BUCKET = "system.configs.oss.aliyun.default-bucket";
public static final String ALLOWED_FILES = "system.configs.oss.aliyun.allowed-files";
public static boolean supported() {
if (!Environments.support("com.aliyun.oss.OSS")) {
return false;
}
String endpoint = CompositeAppConfigProperties.getInstance().getValue(ENDPOINT);
String accessKey = CompositeAppConfigProperties.getInstance().getValue(ACCESS_KEY);
String secretKey = CompositeAppConfigProperties.getInstance().getValue(SECRET_KEY);
String cdnDomain = CompositeAppConfigProperties.getInstance().getValue(CDN_DOMAIN);
String cdnProtocol = CompositeAppConfigProperties.getInstance().getValue(CDN_PROTOCOL);
String[] array = new String[] {
endpoint, accessKey, secretKey, cdnDomain, cdnProtocol
};
return Strings.areNotBlank(array);
}
}
public static class Minio {
public static final String ENDPOINT = "system.configs.oss.minio.endpoint";
public static final String ACCESS_KEY = "system.configs.oss.minio.access-key";
public static final String SECRET_KEY = "system.configs.oss.minio.secret-key";
public static final String CDN_DOMAIN = "system.configs.oss.minio.cdn-domain";
public static final String CDN_PROTOCOL = "system.configs.oss.minio.cdn-protocol";
public static final String DEFAULT_BUCKET = "system.configs.oss.minio.default-bucket";
public static final String ALLOWED_FILES = "system.configs.oss.minio.allowed-files";
public static boolean supported() {
if (!Environments.support("io.minio.MinioClient")) {
return false;
}
String endpoint = CompositeAppConfigProperties.getInstance().getValue(ENDPOINT);
String accessKey = CompositeAppConfigProperties.getInstance().getValue(ACCESS_KEY);
String secretKey = CompositeAppConfigProperties.getInstance().getValue(SECRET_KEY);
String cdnDomain = CompositeAppConfigProperties.getInstance().getValue(CDN_DOMAIN);
String cdnProtocol = CompositeAppConfigProperties.getInstance().getValue(CDN_PROTOCOL);
String[] array = new String[] {
endpoint, accessKey, secretKey, cdnDomain, cdnProtocol
};
return Strings.areNotBlank(array);
}
}
public static class LocalStorage {
public static final String FILE_DIRECTORY = "system.configs.oss.local.file-directory";
public static final String WEB_CONTEXT = "system.configs.oss.local.web-context";
public static final String CDN_DOMAIN = "system.configs.oss.local.cdn-domain";
public static final String CDN_PROTOCOL = "system.configs.oss.local.cdn-protocol";
public static final String DEFAULT_BUCKET = "system.configs.oss.local.default-bucket";
public static final String ALLOWED_FILES = "system.configs.oss.local.allowed-files";
public static final String MAPPING_DIRECT = "system.configs.oss.local.mapping-direct"; // 标记是否直接域名映射到本地目录的(无需通过应用读取文件并预览)
public static boolean supported() {
String fileDir = CompositeAppConfigProperties.getInstance().getValue(FILE_DIRECTORY);
String webCtx = CompositeAppConfigProperties.getInstance().getValue(WEB_CONTEXT);
String cdnDomain = CompositeAppConfigProperties.getInstance().getValue(CDN_DOMAIN);
String cdnProtocol = CompositeAppConfigProperties.getInstance().getValue(CDN_PROTOCOL);
String bucket = CompositeAppConfigProperties.getInstance().getValue(DEFAULT_BUCKET);
String[] array = new String[] {
fileDir, webCtx, cdnDomain, cdnProtocol, bucket
};
return Strings.areNotBlank(array);
}
}
}