-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf($Starter): reduce operating Minio directly
- Loading branch information
1 parent
6dc91ae
commit 6473942
Showing
12 changed files
with
113 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
auth-center/src/main/java/com/jmsoftware/maf/authcenter/configuration/OssConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.jmsoftware.maf.authcenter.configuration; | ||
|
||
import com.jmsoftware.maf.authcenter.remoteapi.osscenter.OssCenterRemoteApi; | ||
import com.jmsoftware.maf.springcloudstarter.poi.OssUploader; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import lombok.val; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.mock.web.MockMultipartFile; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
/** | ||
* Description: OssConfiguration, change description here. | ||
* | ||
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com, date: 9/15/2021 11:51 AM | ||
**/ | ||
@Slf4j | ||
@Configuration | ||
@RequiredArgsConstructor | ||
public class OssConfiguration { | ||
private final OssCenterRemoteApi ossCenterRemoteApi; | ||
|
||
@Bean | ||
public OssUploader ossUploader() { | ||
return (name, inputStream) -> { | ||
MultipartFile file = new MockMultipartFile(name, name, null, inputStream); | ||
val response = this.ossCenterRemoteApi.uploadSingleResource(file); | ||
log.info("Called {} to upload file. {}", OssCenterRemoteApi.SERVICE_NAME, response); | ||
return String.format("%s/%s", response.getData().getBucket(), response.getData().getObject()); | ||
}; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...r/src/main/java/com/jmsoftware/maf/authcenter/remoteapi/osscenter/OssCenterRemoteApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.jmsoftware.maf.authcenter.remoteapi.osscenter; | ||
|
||
import com.jmsoftware.maf.common.bean.ResponseBodyBean; | ||
import com.jmsoftware.maf.common.domain.osscenter.write.ObjectResponse; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
/** | ||
* Description: OssCenterRemoteApi, change description here. | ||
* | ||
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com, date: 9/15/2021 11:10 AM | ||
* @see <a href='https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/'>Spring Cloud OpenFeign</a> | ||
**/ | ||
@FeignClient(value = OssCenterRemoteApi.SERVICE_NAME) | ||
public interface OssCenterRemoteApi { | ||
String SERVICE_NAME = "oss-center"; | ||
|
||
/** | ||
* Upload single resource response body bean. | ||
* | ||
* @param multipartFile the multipart file | ||
* @return the response body bean | ||
*/ | ||
@PostMapping(value = "/upload/single", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) | ||
ResponseBodyBean<ObjectResponse> uploadSingleResource(@RequestPart("file") MultipartFile multipartFile); | ||
} |
1 change: 1 addition & 0 deletions
1
auth-center/src/main/java/com/jmsoftware/maf/authcenter/remoteapi/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package com.jmsoftware.maf.authcenter.remoteapi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
common/src/main/java/com/jmsoftware/maf/common/domain/osscenter/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package com.jmsoftware.maf.common.domain.osscenter; |
2 changes: 1 addition & 1 deletion
2
...sscenter/write/entity/ObjectResponse.java → ...omain/osscenter/write/ObjectResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...center/src/main/java/com/jmsoftware/maf/osscenter/write/service/WriteResourceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...ng-cloud-starter/src/main/java/com/jmsoftware/maf/springcloudstarter/poi/OssUploader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.jmsoftware.maf.springcloudstarter.poi; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* Description: OssUploader, change description here. | ||
* | ||
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com, date: 9/15/2021 11:40 AM | ||
**/ | ||
@FunctionalInterface | ||
public interface OssUploader { | ||
/** | ||
* Upload. | ||
* | ||
* @param name the name | ||
* @param inputStream the input stream | ||
* @return the string | ||
* @throws IOException the io exception | ||
*/ | ||
String upload(String name, InputStream inputStream) throws IOException; | ||
} |