com.github.javaclub.ossclient.OSS Maven / Gradle / Ivy
package com.github.javaclub.ossclient;
import com.github.javaclub.BizException;
import com.github.javaclub.ossclient.impl.AliyunOssClient;
import com.github.javaclub.ossclient.impl.LocalOssClient;
import com.github.javaclub.ossclient.impl.MinioOssClient;
import com.github.javaclub.toolbox.ToolBox.Objects;
import com.github.javaclub.toolbox.conf.CompositeAppConfigProperties;
import com.github.javaclub.toolbox.spring.BeanFactory;
public final class OSS {
public static OssClient get() {
String provider = CompositeAppConfigProperties.getInstance().getValue(OssConstants.OSS_DEFAULT_PROVIDER);
Objects.requireNotEmpty(provider, "Oss 服务提供类型配置缺失!");
OssClient client = null;
switch (provider) {
case "aliyun":
client = BeanFactory.getInstance().getBean(AliyunOssClient.class);
break;
case "minio":
client = BeanFactory.getInstance().getBean(MinioOssClient.class);
break;
case "local":
client = BeanFactory.getInstance().getBean(LocalOssClient.class);
break;
default:
throw new BizException("暂不支持Oss服务类型: " + provider);
}
if (null == client) {
throw new BizException("OssClient尚未初始化!");
}
return client;
}
}