Skip to content

Commit

Permalink
perf($Minio): correct Minio properties
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Aug 1, 2021
1 parent 810af56 commit 1dd7929
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.jmsoftware.maf.osscenter.write.service.impl;

import cn.hutool.core.util.StrUtil;
import com.jmsoftware.maf.osscenter.write.service.WriteResourceService;
import com.jmsoftware.maf.common.exception.BusinessException;
import com.jmsoftware.maf.osscenter.write.service.WriteResourceService;
import com.jmsoftware.maf.springcloudstarter.helper.MinioHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -38,9 +38,11 @@ public String uploadSingleResource(@NotNull MultipartFile multipartFile) throws
}
val mediaType = MediaType.parse(detectedMediaType);
val mediaBaseType = mediaType.getType();
minioHelper.makeBucket(mediaBaseType);
final var put = minioHelper.put(mediaBaseType, multipartFile.getOriginalFilename(), multipartFile);
log.info("Uploaded single resource: {}/{}", put.bucket(), put.object());
return String.format("%s/%s", put.bucket(), put.object());
val bucketMade = this.minioHelper.makeBucket(mediaBaseType);
val objectWriteResponse = this.minioHelper.put(mediaBaseType, multipartFile.getOriginalFilename(),
multipartFile);
log.info("Uploaded single resource: {}/{}. bucketMade: {}", objectWriteResponse.bucket(),
objectWriteResponse.object(), bucketMade);
return String.format("%s/%s", objectWriteResponse.bucket(), objectWriteResponse.object());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import io.minio.MinioClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
* <h1>MinioConfiguration</h1>
Expand All @@ -15,18 +15,18 @@
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com, date: 6/7/21 9:58 PM
**/
@Slf4j
@Import({
MinioProperty.class
@EnableConfigurationProperties({
MinioProperties.class
})
@ConditionalOnProperty({"minio.enabled"})
public class MinioConfiguration {
@Bean
public MinioClient minioClient(MinioProperty minioProperty) {
public MinioClient minioClient(MinioProperties minioProperties) {
log.warn("Initial bean: '{}'", MinioClient.class.getSimpleName());
return MinioClient.builder()
.endpoint(minioProperty.getEndpoint(), minioProperty.getPort(),
minioProperty.getSecure())
.credentials(minioProperty.getAccessKey(), minioProperty.getSecretKey())
.endpoint(minioProperties.getEndpoint(), minioProperties.getPort(),
minioProperties.getSecure())
.credentials(minioProperties.getAccessKey(), minioProperties.getSecretKey())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
@Data
@Validated
@ConfigurationProperties(prefix = MinioProperty.PREFIX)
public class MinioProperty {
@ConfigurationProperties(prefix = MinioProperties.PREFIX)
public class MinioProperties {
/**
* The constant PREFIX.
*/
Expand Down

0 comments on commit 1dd7929

Please sign in to comment.