use of com.ruoyi.oss.exception.OssException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class OssFactory method instance.
/**
* 根据类型获取实例
*/
public static IOssStrategy instance(String type) {
OssEnumd enumd = OssEnumd.find(type);
if (enumd == null) {
throw new OssException("文件存储服务类型无法找到!");
}
AbstractOssStrategy strategy = getStrategy(type);
if (!strategy.isInit) {
refresh(type);
}
return strategy;
}
use of com.ruoyi.oss.exception.OssException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class AliyunOssStrategy method getEndpointLink.
@Override
public String getEndpointLink() {
String endpoint = properties.getEndpoint();
StringBuilder sb = new StringBuilder(endpoint);
if (StringUtils.containsAnyIgnoreCase(endpoint, "http://")) {
sb.insert(7, properties.getBucketName() + ".");
} else if (StringUtils.containsAnyIgnoreCase(endpoint, "https://")) {
sb.insert(8, properties.getBucketName() + ".");
} else {
throw new OssException("Endpoint配置错误");
}
return sb.toString();
}
use of com.ruoyi.oss.exception.OssException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class AliyunOssStrategy method init.
@Override
public void init(OssProperties ossProperties) {
super.init(ossProperties);
try {
ClientConfiguration configuration = new ClientConfiguration();
if (OssConstant.IS_HTTPS.equals(ossProperties.getIsHttps())) {
configuration.setProtocol(Protocol.HTTPS);
}
DefaultCredentialProvider credentialProvider = new DefaultCredentialProvider(properties.getAccessKey(), properties.getSecretKey());
client = new OSSClient(properties.getEndpoint(), credentialProvider, configuration);
createBucket();
} catch (Exception e) {
throw new OssException("阿里云存储配置错误! 请检查系统配置:[" + e.getMessage() + "]");
}
isInit = true;
}
use of com.ruoyi.oss.exception.OssException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class AliyunOssStrategy method upload.
@Override
public UploadResult upload(InputStream inputStream, String path, String contentType) {
try {
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentType(contentType);
client.putObject(new PutObjectRequest(properties.getBucketName(), path, inputStream, metadata));
} catch (Exception e) {
throw new OssException("上传文件失败,请检查阿里云配置信息:[" + e.getMessage() + "]");
}
return UploadResult.builder().url(getEndpointLink() + "/" + path).filename(path).build();
}
use of com.ruoyi.oss.exception.OssException in project RuoYi-Flowable-Plus by KonBAI-Q.
the class QcloudOssStrategy method getEndpointLink.
@Override
public String getEndpointLink() {
String endpoint = properties.getEndpoint();
StringBuilder sb = new StringBuilder(endpoint);
if (StringUtils.containsAnyIgnoreCase(endpoint, "http://")) {
sb.insert(7, properties.getBucketName() + ".");
} else if (StringUtils.containsAnyIgnoreCase(endpoint, "https://")) {
sb.insert(8, properties.getBucketName() + ".");
} else {
throw new OssException("Endpoint配置错误");
}
return sb.toString();
}
Aggregations