fix 修复 minio 适配 https 导致的问题

feature/model
疯狂的狮子li 3 years ago
parent 587fb27484
commit bb793d71e7

@ -9,6 +9,8 @@ import com.ruoyi.oss.exception.OssException;
import com.ruoyi.oss.properties.OssProperties; import com.ruoyi.oss.properties.OssProperties;
import com.ruoyi.oss.service.abstractd.AbstractOssStrategy; import com.ruoyi.oss.service.abstractd.AbstractOssStrategy;
import io.minio.*; import io.minio.*;
import io.minio.http.HttpUtils;
import okhttp3.HttpUrl;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -29,10 +31,15 @@ public class MinioOssStrategy extends AbstractOssStrategy {
public void init(OssProperties ossProperties) { public void init(OssProperties ossProperties) {
super.init(ossProperties); super.init(ossProperties);
try { try {
minioClient = MinioClient.builder() MinioClient.Builder builder = MinioClient.builder();
.endpoint(properties.getEndpoint(), 443, OssConstant.IS_HTTPS.equals(ossProperties.getIsHttps())) if (OssConstant.IS_HTTPS.equals(ossProperties.getIsHttps())) {
.credentials(properties.getAccessKey(), properties.getSecretKey()) HttpUrl url = HttpUtils.getBaseUrl(properties.getEndpoint())
.build(); .newBuilder().scheme("https").build();
builder.endpoint(url);
} else {
builder.endpoint(properties.getEndpoint());
}
minioClient = builder.credentials(properties.getAccessKey(), properties.getSecretKey()).build();
createBucket(); createBucket();
} catch (Exception e) { } catch (Exception e) {
throw new OssException("Minio存储配置错误! 请检查系统配置:[" + e.getMessage() + "]"); throw new OssException("Minio存储配置错误! 请检查系统配置:[" + e.getMessage() + "]");

Loading…
Cancel
Save