1 Star 0 Fork 112

rookey / dante-oss

forked from 码匠君 / dante-oss 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

Dante OSS

丰富 · 全面 | 简单 · 便捷

让 Minio 的集成和使用更简单


Spring Boot 3.1.0 Version 0.5.0 Java 17 License Apache 2.0 Total Visits 码匠君 Github star Github fork Gitee star Gitee fork

示例微服务应用   |   示例单体应用   |   示例前端应用

如果您觉得有帮助,请点右上角 "Star" 支持一下,谢谢!

简介 | Intro

Dante OSS 是一款简化Minio操作的开源框架。通过对原有 Minio Java SDK 的深度封装,简化 Minio API 使用复杂度,提升 Minio 使用的便捷性,降低 Minio 应用开发门槛。

MinIO 是一款高性能、分布式的对象存储系统。Minio这款开源的分布式对象存储服务在国外已经相当受欢迎,并且国内也有多中小型互联网公司使用它来作为对象存储服务。虽然 Minio 相关的资料和示例在网络上已经非常丰富,但是为什么还要推出 Dante OSS 这样的项目?

  • 初次接触 Minio,特别是想要通过 Java 集成 Minio 开发对象存储应用是,还是需要投入一定的时间和精力去了解其原理阅读相关文档。
  • Minio SDK 中的函数方法,涉及的参数较多,抽象层度比较高,每次使用都需要反复查阅源代码才能摸清具体使用方式。
  • 想要与已有的应用进行整合,多少都要投入时间精力,进行一定程度的封装和改造。
  • 网上相关资料多,要么比较零散不成体系,要么比较单一仅针对常规上传下载应用,Minio 自身很多特性都不涉及。

优点 | Advantages

  • 零额外学习成本: 开发者只要会 Spring 和 REST 基本开发,即可无缝集成和使用 Dante OSS
  • 降低开发者门槛: 屏蔽 Minio 标准 Java SDK 使用复杂度,使用 Spring 环境标准方式对原有 API 进行简化封装。Service API 和 REST API 开箱即用
  • 包含的功能丰富: 改造了 Minio Java SDK 的几乎全部功能,且对大文件分片上传、秒传、直传、断点续传等功能,均采用业内最优解决方案进行实现和融合
  • 规范优雅的代码: 所有函数参数,并未破坏原有 Minio 代码构造器结构,而是在原有方式的基础上抽象简化,编程体验和代码可读性大幅提升
  • 完善的注释文档: 对请求参数、方法、REST API、Validation 提供详实的注释、说明和 OpenAPI 标注,用途用法一目了然,无需再翻阅 Minio 文档和源代码,帮助您节省更多时间
  • 完整的前端示例:前端采用一个完整的项目而非Demo的形式,全面的展示了前后端交互涉及、接口调用、参数使用、TS 类型定义等各方面内容,可直接用于实际项目或简单改造后构建自己的产品

对比 | Compare

1. 不只是简单的 Spring Boot Starter 构建

  1. 构建统一的错误,可以返回更人性化、更易理解的错误信息,同时兼顾更详细错误信息的返回,方便开发人员理解和定位问题。
  2. 采用更易理解和使用的格式对 Minio Java SDK 参数进行重新定义。规避 Minio 默认 XML 方式参数多、不易理解使用、与前端交互不方便等问题。
  3. 隐藏 Minio Java SDK 不易理解和使用的细节,提供详实的注释说明,开发人员在使用时无需再通过翻阅 Minio 在线文档和源代码来了解各个 API 使用细节。
  4. 提供统一标准的 REST API,以及 OpenAPI Swagger3 文档描述和准确的 Spring Validation 校验,可直接集成至系统中使用。
  5. Minio Client 对象池、自定义极简 Minio Server 访问反向代理,提升

2. 标准化业务逻辑和解决方案集合

  1. 不只是上传、下载等常用方法的封装,涵盖 Minio Java SDK 支持的所有方法和操作。
  2. 选择业内最优的解决方案,实现和集成大文件分片上传、秒传、直传、断点续传等主要业务需求功能。
  3. 结合自身应用经验和需求,将 Minio API 进一步组合成符合实际应用的业务逻辑和功能处理。
  4. 采用一个基于 Vue3、Typescript5、Vite4、Pinia 2 的完整的前端项目作为集成示例,包括详细的 Typescript 类型定义以及 vue-simple-uploader 等主流组件集成和使用方法。
  5. 提供基于 Spring Authorization Server 的单体版、微服务版案例,从 SDK、Spring Boot Starter 到完整项目任你选择。

3. 具体差异说明

  • [1] 基础API方法以及方法参数
Minio SDK Dante OSS
仅包含基础操作API 提供大量重载方法
必须用构造器创建参数对象 重载方法覆盖所有常见参数,按需传参即可
API全部混在同一个类中 根据差异、用途、场景拆分为不同的 Service,例如:getObject 和 downloadObject
源于XML对象参数结构复杂 自定义实体和转换器简化参数结构
基础API会抛出大量 Exception,具体问题需要自己摸索对应 对所有错误进行标准化处理,提供更准确和交互友好的描述信息,可方便地与系统错误体系融合
  • [2] 前后端交互
Minio SDK Dante OSS
复杂结构参数不利于JSON互转 采用最简化参数方便传输并可准确转换成对应Minio复杂对象参数
参数层次结构复杂 自定义请求参数实体保持继承结构的同时简化传递参数
参数多用途不明晰必须查阅源代码 使用 OpenAPI 注解详细说明各参数用途可使用 Swagger 查阅
参数校验规则细节多没有文档说明 对照 Minio 源代码,结合自定义实体,增加匹配的 Spring Validation 校验
不提供 REST API 提供标准的 REST API 可直接使用
  • [3] 业务支持
内容 Minio SDK Dante OSS
常规业务 独立方法需要自己按需组合 封装常规业务逻辑,可直接调用 REST API使用
设置管理 对于存储桶、对象的管理只能通过 Minio 服务器管理界面 对照 Minio 管理界面方式,将管理功能封装为 Service、REST API 以及 Vue 管理界面
文件直传 提供直传机制,直接暴露Minio服务器地址 增加超简化反向代理,在满足直传需求的前提下,很好的隐藏Minio 服务器以提升安全性
文件直传 直传接口无法与现有系统安全体系融合(无法鉴权) 提供基于 Spring Authorization Server 的、完整的单体版和微服务版案例
大文件分片 内部机制无法直接使用 封装主流大文件分片方案,提供前后端使用案例
文件秒传 不支持 提供共用化秒传实现,可直接使用,支持多种数据库
  • [4] 前端开发
Dante OSS
只要Minio API支持,对应的管理功能均会在标准的 Vue3 工程中实现
提供与后端一致 Typescript 声明文件,可以直接用于基于Typescript的前端开发
完整的、基于 Vue3、Vite4、Typescript5 的前端项目案例,可清晰的了解 Minio 前后端交互和使用,甚至直接使用

结构 | Structure

dante-oss
├── oss-bom -- 工程Maven顶级依赖,统一控制版本和依赖
├── oss-minio -- Minio 模块
├    ├── minio-core -- Minio 通用代码包
├    ├── minio-sdk-logic -- Minio 基础 API 模块
├    ├── minio-sdk-rest -- Minio 基础 REST API模块
├    ├── minio-sdk-scenario -- Minio 扩展及应用方案整合模块
├    └── minio-spring-boot-starter -- 仅包含 Minio 基础 API 和 REST API 的 Starter
└── oss-spring-boot-starter -- 完整的、包含所有内容的 Starter

功能 | function

  • [1] 基础功能
功能 说明
Bucket 列表 Bucket 列表查询,包括 Service、REST API 和前端展示
Bucket 名称是否存在 Bucket 名是否存在,包括 Service、REST API 和前端异步校验处理
Bucket 创建 创建 Bucket,包括 Service、REST API 和前端Validation校验处理
Bucket 删除 删除 Bucket,包括 Service、REST API 和前端展示处理
Bucket 加密设置获取 获取 Bucket Encryption 设置,包括 Service、REST API
Bucket 修改加密设置 修改 Bucket Encryption 设置,包括 Service、REST API
Bucket 删除加密设置 删除 Bucket Encryption 设置,包括 Service、REST API
Bucket 访问策略设置获取 获取 Bucket Policy 设置,包括 Service、REST API
Bucket 修改访问策略设置 修改 Bucket Policy 设置,包括 Service、REST API
Bucket 删除访问策略设置 删除 Bucket Policy 设置,包括 Service、REST API
Bucket 标签获取 获取 Bucket Tags,包括 Service、REST API
Bucket 修改标签 修改 Bucket Tags,包括 Service、REST API
Bucket 删除标签 删除 Bucket Tags,包括 Service、REST API
Bucket 对象锁定设置获取 获取 Bucket ObjectLockConfiguration 设置,包括 Service、REST API
Bucket 修改对象锁定设置 修改 Bucket ObjectLockConfiguration 设置,包括 Service、REST API
Bucket 删除对象锁定设置 删除 Bucket ObjectLockConfiguration 设置,包括 Service、REST API
Object 列表 Object 列表查询,包括 Service、REST API 和前端展示
Object 删除 删除 Object,包括 Service、REST API 和前端展示处理
Object 批量删除 批量删除 Object,包括 Service、REST API 和前端展示处理
Object 元信息获取 获取 Object Stat,包括 Service、
Object 下载(服务端) Object 下载(服务端下载,非流模式),包括 Service、
Object 标签获取 获取 Object Tags,包括 Service、REST API
Object 修改标签 修改 Object Tags,包括 Service、REST API
Object 删除标签 删除 Object Tags,包括 Service、REST API
Object 获取保留设置 获取 Object Retention,包括 Service、REST API
Object 修改保留设置 修改 Object Retention,包括 Service、REST API
Object 开启持有设置 获取 Object LegalHold,包括 Service、REST API
Object 关闭持有设置 修改 Object LegalHold,包括 Service、REST API
其它功能 正逐步完善,主要涉及前后端交互、以及可用性验证和前端相关功能的开发,敬请期待,欢迎 PR
  • [2] 扩展功能
功能 说明
创建分片上传请求 创建分片上传请求,返回 Minio UploadId
创建文件预上传地址 根据 UploadId 和 指定的分片数量,返回数量像匹配的 Minio 与上传地址
获取所有分片文件 获取指定 uploadId 下所有的分片文件
创建大文件分片上传 统一的创建大文件分片上传业务逻辑封装,减少前后端反复交互, 包括 Service、REST API
合并已经上传完成的分片 根据 UploadId 合并已经上传完成的分片,完成大文件分片上传 包括 Service、REST API
统一常量接口 将涉及的 Enums、常量以统一接口的方式返回给前端,方便展示使用, 包括 Service、REST API 和前端展示
Minio Client 对象池 实现 Minio Client 对象池,减少 Minio Client 的反复创建和销毁,提升访问 Minio Server性能
Bucket 设置 统一 Bucket 设置: Bucket 标签设置、访问策略、加密方式、对象锁定等, 包括 Service、REST API 和前端展示
Object 设置 统一 Object 设置: Bucket 标签设置, 包括 Service、REST API 和前端展示
Object 下载(流模式) Minio 对象下载,采用流模式支持vue前端post方式下载, 包括 Service、REST API 和前端展示
超轻量级反向代理 实现轻量级反向代理解决 PresignedObjectUrl 方式直接向前端暴露 Minio Server地址问题
  • [3] 主流方案
功能 说明
OpenAPI 支持 在支持 Open API 环境下,显示 Swagger 文档,建议使用 Springdoc
与 Spring Authorization Server 体系集成 提供完整的与 Spring Authorization Server 集成,实现认证、授权、鉴权、动态权限等完整案例,包括单体版和微服务版
大文件分片上传 采用 PresignedObjectUrl 方案的大文件分片上传。扩展 Minio Client,封装相应的 Service、REST API
vue-simple-uploader 前端基于 vue-simple-uploader 组件,配合自定义 REST API 实现大文件分片上传

使用 | How to use

一、基本使用

  1. maven 中引入
<dependency>
    <groupId>cn.herodotus.oss</groupId>
    <artifactId>oss-spring-boot-starter</artifactId>
    <version>最新版本</version>
</dependency>
  1. 配置 yml 参数
herodotus:
  oss:
    minio:
      endpoint: http://127.0.0.1:9000
      access-key: xxxxxx
      secret-key: xxxxxx

结合实际需求配置数据源

  1. 统一错误处理
// 参考代码
public static Result<String> resolveException(Exception ex String path) {
    return GlobalExceptionHandler.resolveException(ex path);
}

// 或者

@ExceptionHandler({HerodotusException.class PlatformException.class})
public static Result<String> exception(Exception ex HttpServletRequest request HttpServletResponse response) {
    ······
}
  1. 交互性错误信息反馈
// 在系统统一错误处,调用以下代码即可返回包含自定义错误码的、更具交互性错误信息。
if (ex instanceof HerodotusException exception) {
    Result<String> result = exception.getResult();
    result.path(path);
    log.error("[Herodotus] |- Global Exception Handler, Error is : {}", result);
    return result;
}

二、选择使用

除了 minio-core 模块以外,其它所有模块均可以单独使用。可以根据自身需要,仅选择某个模块进行使用。

  • minio-sdk-logic: 仅包含对 Minio 基础 API 封装的 Service 代码。使用注解 @EnableHerodotusMinioLogic 可开启相关内容。
  • minio-sdk-rest: 包含对 Minio 基于 API 封装的 Service 以及 REST 代码。使用注解 @EnableHerodotusMinioRest 可开启相关内容。
  • minio-sdk-scenario: 包含扩展应用以及各OSS常规场景应用, 注意:不包含 minio-sdk-rest 内容。使用注解 @EnableHerodotusMinioScenario 可开启相关内容。
  • minio-spring-boot-starter: 包含 minio-sdk-logicminio-sdk-rest 两部分内容,可直接引入使用。
  • oss-spring-boot-starter: 包含所有内容,注意:需要依赖数据库等相关内容。

贡献 | Committer

  1. 在Gitee fork项目到自己的repo
  2. 把fork过去的项目也就是你的项目clone到你的本地
  3. 修改代码(记得一定要修改 develop 分支)
  4. commit 代码,push 到自己的库(develop分支)
  5. 登录Gitee 在你首页可以看到一个 pull request 按钮,点击它,填写一些说明信息,然后提交即可。
  6. 等待维护者合并

反馈 | Feedback

  • 欢迎提交ISSUS ,请写清楚问题的具体原因,重现步骤和环境

演示 | Example

Dante OSS 作为 Dante Cloud 生态产品,不在单独提供演示环境和示例,请直接使用 Dante 环境查看效果和了解使用,这样也更贴近实际。

注意:如果您仅是想了解基本的使用方式和使用效果,建议使用单体架构演示环境。具体搭建方式参见【在线文档】中,单体版章节。

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright (c) 2020-2030 ZHENGGENGWEI(码匠君)<herodotus@aliyun.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Dante OSS 采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: 1.请不要删除和修改根目录下的LICENSE文件。 2.请不要删除和修改 Dante Cloud 源码头部的版权声明。 3.请保留源码和相关描述文件的项目出处,作者声明等。 4.分发源码时候,请注明软件出处 <https://gitee.com/herodotus/dante-oss> 5.在修改包名,模块名称,项目代码等时,请注明软件出处 <https://gitee.com/herodotus/dante-oss> 6.若您的项目无法满足以上几点,可申请商业授权

简介

Dante OSS 是一款简化 Minio 操作的开源框架。通过对原有 Minio Java SDK 的深度封装,简化 Minio API 使用复杂度,提升 Minio 使用的便捷性,降低 Minio 应用开发门槛 展开 收起
Java
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/rookey/dante-oss.git
git@gitee.com:rookey/dante-oss.git
rookey
dante-oss
dante-oss
master

搜索帮助