Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 解决minIO无法上传到https的问题 #1458

Merged
merged 1 commit into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/run/halo/app/handler/file/MinioFileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public UploadResult upload(@NonNull MultipartFile file) {
String source =
optionService.getByPropertyOrDefault(MinioProperties.SOURCE, String.class, "");
String region =
optionService.getByPropertyOfNonNull(MinioProperties.REGION).toString();
optionService.getByPropertyOrDefault(MinioProperties.REGION, String.class, "us-east-1");
JohnNiang marked this conversation as resolved.
Show resolved Hide resolved

endpoint = StringUtils.appendIfMissing(endpoint, HaloConst.URL_SEPARATOR);

Expand All @@ -78,6 +78,7 @@ public UploadResult upload(@NonNull MultipartFile file) {
.stream(file.getInputStream(), file.getSize(), -1)
.object(upFilePath)
.build();
minioClient.ignoreCertCheck();
minioClient.putObject(putObjectArgs);

UploadResult uploadResult = new UploadResult();
Expand Down Expand Up @@ -114,7 +115,7 @@ public void delete(@NonNull String key) {
String bucketName =
optionService.getByPropertyOfNonNull(MinioProperties.BUCKET_NAME).toString();
String region =
optionService.getByPropertyOfNonNull(MinioProperties.REGION).toString();
optionService.getByPropertyOrDefault(MinioProperties.REGION, String.class, "us-east-1");
JohnNiang marked this conversation as resolved.
Show resolved Hide resolved

MinioClient minioClient = MinioClient.builder()
.endpoint(endPoint)
Expand All @@ -123,6 +124,7 @@ public void delete(@NonNull String key) {
.build();

try {
minioClient.ignoreCertCheck();
minioClient.removeObject(RemoveObjectArgs.builder()
.bucket(bucketName)
.object(key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum MinioProperties implements PropertyEnum {
/**
* Minio regoin
*/
REGION("minio_region", String.class, "");
REGION("minio_region", String.class, "us-east-1");
JohnNiang marked this conversation as resolved.
Show resolved Hide resolved

private final String value;

Expand Down