Skip to content

Commit

Permalink
!12 v0.7.0
Browse files Browse the repository at this point in the history
Merge pull request !12 from 码匠君/develop
  • Loading branch information
herodotus-ecosystem authored and gitee-org committed Jun 21, 2023
2 parents f3c2697 + b6ad46a commit 9c1e65e
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 95 deletions.
35 changes: 18 additions & 17 deletions .gitee/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@ description: 当你中发现了一个 Bug,导致应用崩溃或抛出异常,
title: "[Bug]: "
labels: ["bug"]
body:
- type: markdown
- type: input
attributes:
value: |
感谢对项目的支持与关注。在提出问题之前,请确保您已查看相关开发或使用文档:
- https://www.herodotus.cn
label: 当前代码版本
description: 请准确说明你当前使用的代码版本,包括前端代码版本和后端代码版本。
validations:
required: true
- type: checkboxes
attributes:
label: 下载代码的前端和后端版本的一致性?
options:
- label: 我承诺已经认真检查过,前端工程代码版本和后端代码版本一致
required: true
- type: checkboxes
attributes:
label: 在线文档和提问的智慧是否已经过?
options:
- label: 我承诺已经认真详细的看过文档 (https://www.herodotus.cn)
required: true
- type: checkboxes
attributes:
label: 这个问题是否已经存在?
Expand All @@ -16,7 +29,7 @@ body:
required: true
- type: textarea
attributes:
label: 如何复现
label: 如何复现重现这个问题,具体步骤是什么?
description: 请详细告诉我们如何复现你遇到的问题,如涉及代码,可提供一个最小代码示例,并使用反引号```附上它
placeholder: |
1. ...
Expand All @@ -34,17 +47,5 @@ body:
attributes:
label: 实际结果
description: 请告诉我们实际发生了什么。
validations:
required: true
- type: textarea
attributes:
label: 截图或视频
description: 如果可以的话,上传任何关于 bug 的截图。
value: |
[在这里上传图片]
- type: textarea
attributes:
label: 代码版本
description: 请准确说明你当前使用的代码版本,具体版本信息参见pom.xml。
validations:
required: true
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<p align="center">
<a href="https://spring.io/projects/spring-boot" target="_blank"><img src="https://shields.io/badge/Spring%20Boot-3.1.0-blue.svg?logo=spring" alt="Spring Boot 3.1.0"></a>
<a href="#" target="_blank"><img src="https://shields.io/badge/Version-0.6.0-red.svg?logo=spring" alt="Version 0.6.0"></a>
<a href="#" target="_blank"><img src="https://shields.io/badge/Version-0.7.0-red.svg?logo=spring" alt="Version 0.7.0"></a>
<a href="https://bell-sw.com/pages/downloads/#downloads" target="_blank"><img src="https://img.shields.io/badge/JDK-17%2B-green.svg?logo=openjdk" alt="Java 17"></a>
<a href="./LICENSE"><img src="https://shields.io/badge/License-Apache--2.0-blue.svg?logo=apache" alt="License Apache 2.0"></a>
<a href="https://www.herodotus.cn"><img src="https://visitor-badge.laobi.icu/badge?page_id=dante-cloud&title=Total%20Visits" alt="Total Visits"></a>
Expand All @@ -16,7 +16,9 @@
<a href="https://gitee.com/herodotus/dante-oss"><img src="https://gitee.com/herodotus/dante-oss/badge/star.svg?theme=dark" alt="Gitee star"></a>
<a href="https://gitee.com/herodotus/dante-oss"><img src="https://gitee.com/herodotus/dante-oss/badge/fork.svg?theme=dark" alt="Gitee fork"></a>
</p>

<p align="center">
<a href="https://www.murphysec.com/console/report/1669933209810452480/1669933209848201216" alt="Security Status"><img src="https://www.murphysec.com/platform3/v31/badge/1669933209848201216.svg" /></a>
</p>
<p align="center">
<a href="https://gitee.com/dromara/dante-cloud">示例微服务应用</a> &nbsp; | &nbsp;
<a href="https://gitee.com/herodotus/dante-cloud-athena">示例单体应用</a> &nbsp; | &nbsp;
Expand Down
4 changes: 2 additions & 2 deletions oss-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<groupId>cn.herodotus.oss</groupId>
<artifactId>oss-bom</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
<packaging>pom</packaging>

<description>Dante Cloud 生态产品 Dante OSS Bom</description>
Expand Down Expand Up @@ -89,7 +89,7 @@
<mapstruct-processor.version>1.5.5.Final</mapstruct-processor.version>

<spring-boot-dependencies.version>3.1.0</spring-boot-dependencies.version>
<dante-bom.version>3.1.0.7</dante-bom.version>
<dante-bom.version>3.1.0.8</dante-bom.version>
</properties>

<dependencyManagement>
Expand Down
4 changes: 2 additions & 2 deletions oss-minio/minio-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
<parent>
<groupId>cn.herodotus.oss</groupId>
<artifactId>oss-minio</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
</parent>

<artifactId>minio-core</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
<packaging>jar</packaging>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import cn.herodotus.oss.minio.core.domain.ObjectWriteDomain;
import cn.herodotus.oss.minio.core.utils.ConverterUtils;
import io.minio.ObjectWriteResponse;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.core.convert.converter.Converter;

/**
Expand All @@ -39,13 +40,17 @@
public class ResponseToObjectWriteDomainConverter implements Converter<ObjectWriteResponse, ObjectWriteDomain> {
@Override
public ObjectWriteDomain convert(ObjectWriteResponse response) {
ObjectWriteDomain domain = new ObjectWriteDomain();
domain.setEtag(response.etag());
domain.setVersionId(response.versionId());
domain.setHeaders(ConverterUtils.toMap(response.headers().toMultimap()));
domain.setBucketName(response.bucket());
domain.setRegion(response.region());
domain.setObjectName(response.object());
return domain;
if (ObjectUtils.isNotEmpty(response)) {
ObjectWriteDomain domain = new ObjectWriteDomain();
domain.setEtag(response.etag());
domain.setVersionId(response.versionId());
domain.setHeaders(ConverterUtils.toMap(response.headers().toMultimap()));
domain.setBucketName(response.bucket());
domain.setRegion(response.region());
domain.setObjectName(response.object());
return domain;
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,21 @@ public ObjectDomain convert(Result<Item> result) {
try {
Item item = result.get();
ObjectDomain entity = new ObjectDomain();
entity.setEtag(item.etag());
entity.setObjectName(item.objectName());
entity.setLastModified(DateTimeUtils.zonedDateTimeToString(item.lastModified()));
if (ObjectUtils.isNotEmpty(item.owner())) {
entity.setOwnerId(item.owner().id());
entity.setOwnerDisplayName(item.owner().displayName());
}
entity.setSize(item.size());
entity.setStorageClass(item.storageClass());
entity.setLatest(item.isLatest());
entity.setUserMetadata(item.userMetadata());
entity.setDir(item.isDir());
if (!item.isDir()) {
entity.setEtag(item.etag());
entity.setLastModified(DateTimeUtils.zonedDateTimeToString(item.lastModified()));
if (ObjectUtils.isNotEmpty(item.owner())) {
entity.setOwnerId(item.owner().id());
entity.setOwnerDisplayName(item.owner().displayName());
}
entity.setSize(item.size());
entity.setStorageClass(item.storageClass());
entity.setUserMetadata(item.userMetadata());
}

return entity;
} catch (ErrorResponseException e) {
log.error("[Herodotus] |- Minio catch ErrorResponseException in [{}].", function, e);
Expand Down
4 changes: 2 additions & 2 deletions oss-minio/minio-sdk-logic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
<parent>
<groupId>cn.herodotus.oss</groupId>
<artifactId>oss-minio</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
</parent>

<artifactId>minio-sdk-logic</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
<packaging>jar</packaging>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ConnectException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
Expand Down Expand Up @@ -1004,32 +1005,15 @@ public StatObjectResponse statObject(StatObjectArgs statObjectArgs) {
* · 默认情况下,如果已存在同名Object且对该Object有访问权限,则新添加的Object将覆盖原有的Object,并返回200 OK。
* · OSS没有文件夹的概念,所有资源都是以文件来存储,但您可以通过创建一个以正斜线(/)结尾,大小为0的Object来创建模拟文件夹。
*
* @param bucketName 存储桶名称
* @param objectName 对象名称
* @param stream 文件流
* @param objectSize 对象大小
* @return {@link ObjectWriteResponse}
*/
public ObjectWriteResponse putObject(String bucketName, String objectName, BufferedInputStream stream, long objectSize) {
return putObject(bucketName, null, objectName, stream, objectSize, -1);
}

/**
* 上传文件
* <p>
* · 添加的Object大小不能超过5 TB。
* · 默认情况下,如果已存在同名Object且对该Object有访问权限,则新添加的Object将覆盖原有的Object,并返回200 OK。
* · OSS没有文件夹的概念,所有资源都是以文件来存储,但您可以通过创建一个以正斜线(/)结尾,大小为0的Object来创建模拟文件夹。
*
* @param bucketName 存储桶名称
* @param objectName 对象名称
* @param stream 文件流
* @param objectSize 对象大小
* @param partSize 分片大小
* @param bucketName 存储桶名称
* @param objectName 对象名称
* @param stream 文件流
* @param objectSize 对象大小
* @param contentType 内容类型
* @return {@link ObjectWriteResponse}
*/
public ObjectWriteResponse putObject(String bucketName, String objectName, BufferedInputStream stream, long objectSize, long partSize) {
return putObject(bucketName, null, objectName, stream, objectSize, partSize);
public ObjectWriteResponse putObject(String bucketName, String objectName, InputStream stream, long objectSize, String contentType) {
return putObject(bucketName, null, objectName, stream, objectSize, -1 , contentType);
}

/**
Expand All @@ -1039,16 +1023,16 @@ public ObjectWriteResponse putObject(String bucketName, String objectName, Buffe
* · 默认情况下,如果已存在同名Object且对该Object有访问权限,则新添加的Object将覆盖原有的Object,并返回200 OK。
* · OSS没有文件夹的概念,所有资源都是以文件来存储,但您可以通过创建一个以正斜线(/)结尾,大小为0的Object来创建模拟文件夹。
*
* @param bucketName 存储桶名称
* @param region 区域
* @param objectName 对象名称
* @param stream 文件流
* @param objectSize 对象大小
* @param partSize 分片大小
* @param bucketName 存储桶名称
* @param objectName 对象名称
* @param stream 文件流
* @param objectSize 对象大小
* @param partSize 分片大小
* @param contentType 内容类型
* @return {@link ObjectWriteResponse}
*/
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, BufferedInputStream stream, long objectSize, long partSize) {
return putObject(bucketName, region, objectName, stream, objectSize, partSize, null);
public ObjectWriteResponse putObject(String bucketName, String objectName, InputStream stream, long objectSize, long partSize, String contentType) {
return putObject(bucketName, null, objectName, stream, objectSize, partSize, contentType);
}

/**
Expand All @@ -1067,7 +1051,7 @@ public ObjectWriteResponse putObject(String bucketName, String region, String ob
* @param contentType 内容类型
* @return {@link ObjectWriteResponse}
*/
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, BufferedInputStream stream, long objectSize, long partSize, String contentType) {
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, InputStream stream, long objectSize, long partSize, String contentType) {
return putObject(bucketName, region, objectName, stream, objectSize, partSize, contentType, false);
}

Expand All @@ -1088,7 +1072,7 @@ public ObjectWriteResponse putObject(String bucketName, String region, String ob
* @param legalHold 是否保持
* @return {@link ObjectWriteResponse}
*/
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, BufferedInputStream stream, long objectSize, long partSize, String contentType, boolean legalHold) {
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, InputStream stream, long objectSize, long partSize, String contentType, boolean legalHold) {
return putObject(bucketName, region, objectName, stream, objectSize, partSize, contentType, legalHold, null);
}

Expand All @@ -1110,7 +1094,7 @@ public ObjectWriteResponse putObject(String bucketName, String region, String ob
* @param retention 保存设置
* @return {@link ObjectWriteResponse}
*/
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, BufferedInputStream stream, long objectSize, long partSize, String contentType, boolean legalHold, Retention retention) {
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, InputStream stream, long objectSize, long partSize, String contentType, boolean legalHold, Retention retention) {
return putObject(bucketName, region, objectName, stream, objectSize, partSize, contentType, legalHold, retention, null);
}

Expand All @@ -1133,7 +1117,7 @@ public ObjectWriteResponse putObject(String bucketName, String region, String ob
* @param tags 标签
* @return {@link ObjectWriteResponse}
*/
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, BufferedInputStream stream, long objectSize, long partSize, String contentType, boolean legalHold, Retention retention, Tags tags) {
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, InputStream stream, long objectSize, long partSize, String contentType, boolean legalHold, Retention retention, Tags tags) {
return putObject(bucketName, region, objectName, stream, objectSize, partSize, contentType, legalHold, retention, tags, null);
}

Expand All @@ -1157,7 +1141,7 @@ public ObjectWriteResponse putObject(String bucketName, String region, String ob
* @param sse 服务加密
* @return {@link ObjectWriteResponse}
*/
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, BufferedInputStream stream, long objectSize, long partSize, String contentType, boolean legalHold, Retention retention, Tags tags, ServerSideEncryption sse) {
public ObjectWriteResponse putObject(String bucketName, String region, String objectName, InputStream stream, long objectSize, long partSize, String contentType, boolean legalHold, Retention retention, Tags tags, ServerSideEncryption sse) {
return putObject(PutObjectArgs.builder()
.bucket(bucketName)
.region(region)
Expand Down
4 changes: 2 additions & 2 deletions oss-minio/minio-sdk-rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
<parent>
<groupId>cn.herodotus.oss</groupId>
<artifactId>oss-minio</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
</parent>

<artifactId>minio-sdk-rest</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
<packaging>jar</packaging>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions oss-minio/minio-sdk-scenario/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
<parent>
<groupId>cn.herodotus.oss</groupId>
<artifactId>oss-minio</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
</parent>

<artifactId>minio-sdk-scenario</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
<packaging>jar</packaging>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
package cn.herodotus.oss.minio.scenario.controller;

import cn.herodotus.engine.rest.core.annotation.Idempotent;
import cn.herodotus.oss.minio.core.domain.ObjectWriteDomain;
import cn.herodotus.oss.minio.scenario.request.ObjectDownloadRequest;
import cn.herodotus.oss.minio.scenario.service.ObjectStreamService;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -36,14 +37,13 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

Expand Down Expand Up @@ -90,4 +90,22 @@ public void download(@Validated @RequestBody ObjectDownloadRequest request, Http
log.error("[Herodotus] |- Download file from minio catch error", e);
}
}

@Idempotent
@Operation(summary = "文件上传", description = "普通的文件上传操作接口",
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(content = @Content(mediaType = "application/json")),
responses = {
@ApiResponse(description = "所有对象", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ObjectWriteDomain.class))),
@ApiResponse(responseCode = "200", description = "操作成功"),
@ApiResponse(responseCode = "500", description = "操作失败"),
@ApiResponse(responseCode = "503", description = "Minio Server无法访问或未启动")
})
@Parameters({
@Parameter(name = "bucketName", required = true, description = "存储桶名称"),
@Parameter(name = "file", required = true, description = "文件", schema = @Schema(implementation = MultipartFile.class))
})
@PostMapping("/upload")
public ObjectWriteDomain upload(@RequestParam(value = "bucketName") String bucketName, @RequestPart(value = "file") MultipartFile file, HttpServletRequest request) {
return objectStreamService.upload(bucketName, file);
}
}
Loading

0 comments on commit 9c1e65e

Please sign in to comment.