Skip to content

Commit

Permalink
Merge pull request #125 from dromara/dev
Browse files Browse the repository at this point in the history
Release 2.0.0
  • Loading branch information
1171736840 authored Oct 18, 2023
2 parents 11e4d1c + 41c7296 commit 933683a
Show file tree
Hide file tree
Showing 142 changed files with 3,176 additions and 915 deletions.
298 changes: 270 additions & 28 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/CNAME
Original file line number Diff line number Diff line change
@@ -1 +1 @@
spring-file-storage.xuyanwu.cn
x-file-storage.xuyanwu.cn
48 changes: 48 additions & 0 deletions docs/Metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Metadata 元数据

## 使用

可以在上传时传入 Metadata 和 UserMetadata ,目前仅 华为云 OBS、阿里云 OSS、腾讯云 COS、百度云 BOS、七牛云 Kodo、又拍云 USS、MinIO、Amazon S3、GoogleCloud Storage 平台支持

```java
//判断是否支持 Metadata
FileStorage storage = fileStorageService.getFileStorage();
boolean supportMetadata = fileStorageService.isSupportMetadata(storage);

//上传并传入 Metadata
FileInfo fileInfo = fileStorageService.of(file)
.putMetadata(Constant.Metadata.CONTENT_DISPOSITION,"attachment;filename=DownloadFileName.jpg")
.putMetadata("Test-Not-Support","123456")//测试不支持的元数据,此数据并不会生效
.putUserMetadata("role","666")
.putThMetadata(Constant.Metadata.CONTENT_DISPOSITION,"attachment;filename=DownloadThFileName.jpg")
.putThUserMetadata("role","777")
.thumbnail()
.upload();
```

> [!WARNING|label:重要提示:]
> 每个存储平台支持的 Metadata 有所不同,例如 七牛云 Kodo 和 又拍云 USS 就不支持 `Content-Disposition`,具体支持情况以每个存储平台的官方文档为准
>
> 在传入 UserMetadata 时,不用传入前缀,例如 `x-amz-meta-` `x-qn-meta-` `x-upyun-meta-`,SDK会自动处理

## 处理异常

默认在不支持的存储平台传入 UserMetadata 会抛出异常,可以通过以下方式不抛出异常

**第一种(全局)**
```yaml
dromara:
x-file-storage:
upload-not-support-metadata-throw-exception: false
```
**第二种(仅当前)**
```java
FileInfo fileInfo = fileStorageService.of(file)
.setNotSupportMetadataThrowException(false) //在不支持 Metadata 的存储平台不抛出异常
.putUserMetadata("role","666")
.upload();
```


313 changes: 284 additions & 29 deletions docs/README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/_footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[我的博客(常年不更新)](https://xuyanwu.cn)
      
[用 JavaScript 在浏览器中控制台观看 BadApple!!](https://app.xuyanwu.cn/BadApple/)
21 changes: 11 additions & 10 deletions docs/_navbar.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
* 文档版本 1.0.3
* 🌟文档版本 2.0.0

* [1.0.3](https://spring-file-storage.xuyanwu.cn/1.0.3/)
* [1.0.2](https://spring-file-storage.xuyanwu.cn/1.0.2/)
* [1.0.1](https://spring-file-storage.xuyanwu.cn/1.0.1/)
* [1.0.0](https://spring-file-storage.xuyanwu.cn/1.0.0/)
* [0.7.0](https://spring-file-storage.xuyanwu.cn/0.7.0/)
* [0.6.1](https://spring-file-storage.xuyanwu.cn/0.6.1/)
* [0.6.0](https://spring-file-storage.xuyanwu.cn/0.6.0/)
* [0.5.0](https://spring-file-storage.xuyanwu.cn/0.5.0/)
* [0.4.0](https://spring-file-storage.xuyanwu.cn/0.4.0/)
* [2.0.0](https://x-file-storage.xuyanwu.cn/2.0.0/)
* [1.0.3](https://x-file-storage.xuyanwu.cn/1.0.3/)
* [1.0.2](https://x-file-storage.xuyanwu.cn/1.0.2/)
* [1.0.1](https://x-file-storage.xuyanwu.cn/1.0.1/)
* [1.0.0](https://x-file-storage.xuyanwu.cn/1.0.0/)
* [0.7.0](https://x-file-storage.xuyanwu.cn/0.7.0/)
* [0.6.1](https://x-file-storage.xuyanwu.cn/0.6.1/)
* [0.6.0](https://x-file-storage.xuyanwu.cn/0.6.0/)
* [0.5.0](https://x-file-storage.xuyanwu.cn/0.5.0/)
* [0.4.0](https://x-file-storage.xuyanwu.cn/0.4.0/)
25 changes: 13 additions & 12 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
* [简介](/ "简介")
* [快速入门](快速入门 "快速入门")
* [基础功能](基础功能 "基础功能")
* [ACL 访问控制列表](acl "ACL 访问控制列表")
* [预签名 URL](预签名URL "签名 URL")
* [存储平台](存储平台 "存储平台")
* [文件适配器](文件适配器 "文件适配器")
* [识别文件的 MIME 类型](识别文件的MIME类型 "识别文件的 MIME 类型")
* [切面](切面 "切面")
* [脱离 SpringBoot 单独使用](脱离SpringBoot单独使用 "脱离 SpringBoot 单独使用")
* [常见问题](常见问题 "常见问题")
* [更新记录](更新记录 "更新记录")
* [📚简介](/ "简介")
* [🍭快速入门](快速入门 "快速入门")
* [🍬基础功能](基础功能 "基础功能")
* [🍉ACL 访问控制列表](acl "ACL 访问控制列表")
* [🥑预签名 URL](预签名URL "签名 URL")
* [🌼Metadata 元数据](Metadata "Metadata 元数据")
* [🥦存储平台](存储平台 "存储平台")
* [🌽文件适配器](文件适配器 "文件适配器")
* [🔍️识别文件的 MIME 类型](识别文件的MIME类型 "识别文件的 MIME 类型")
* [🧪切面](切面 "切面")
* [🌱脱离 SpringBoot 单独使用](脱离SpringBoot单独使用 "脱离 SpringBoot 单独使用")
* [🙋‍♂️常见问题](常见问题 "常见问题")
* [📜更新记录](更新记录 "更新记录")
22 changes: 21 additions & 1 deletion docs/acl.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fileStorageService.setThFileAcl(fileInfo,Constant.ACL.PUBLIC_READ);

一般情况下使用 私有`PRIVATE`、公共读`PUBLIC_READ`、公共读写`PUBLIC_READ_WRITE`这三个就够了,这是所有支持 ACL 的平台都通用的

有些平台也定义了一些私有的 ACL,请查看 `cn.xuyanwu.spring.file.storage.constant` 包下面的 `Constant` 接口中定义的常量
有些平台也定义了一些私有的 ACL,请查看 `org.dromara.x.file.storage.core.constant` 包下面的 `Constant` 接口中定义的常量

因为这样设置的 ACL 都是字符串,可以方便的保存到数据库中,所以推荐使用这种方式

Expand Down Expand Up @@ -132,3 +132,23 @@ ObsClient client = fileStorage.getClient();
AccessControlList acl = client.getObjectAcl(fileStorage.getBucketName(),fileStorage.getFileKey(fileInfo));
```
因为这种方式使用较少,且每个平台返回的的 ACL 都不一样,所以就没有封装统一的方法,一般情况下从`FileInfo`对象直接获取就行了


## 处理异常

默认在不支持的存储平台传入 ACL 会抛出异常,可以通过以下方式不抛出异常

**第一种(全局)**
```yaml
dromara:
x-file-storage:
upload-not-support-alc-throw-exception: false
```
**第二种(仅当前)**
```java
FileInfo fileInfo = fileStorageService.of(file)
.setNotSupportAclThrowException(false) //在不支持 ACL 的存储平台不抛出异常
.setAcl(Constant.ACL.PRIVATE)
.upload();
```
46 changes: 29 additions & 17 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>X Spring File Storage</title>
<meta name="keywords" content="文件存储,对象存储,xuyanwu">
<meta name="description" content="在 SpringBoot 中通过简单的方式将文件存储到阿里云OSS、华为云OBS、七牛云Kodo、腾讯云COS、百度云 BOS、又拍云USS平台">
<title>X File Storage</title>
<meta name="keywords" content="x-file-storage,X Spring File Storage,文件存储,对象存储,xuyanwu">
<meta name="description"
content="原名 X Spring File Storage,一行代码将文件存储到阿里云OSS、华为云OBS、七牛云Kodo、腾讯云COS、百度云 BOS、又拍云USS等平台">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="https://spring-file-storage.xuyanwu.cn/assets/docsify-theme-vue.css">
<link rel="stylesheet" href="https://x-file-storage.xuyanwu.cn/assets/docsify-theme-vue.css">
<style>
#main {
max-width: 90%;
}

.sidebar-nav > ul > li > a:first-child {
font-size: 16px;
font-weight: bold;
}


</style>
</head>
<body>
Expand All @@ -21,9 +29,11 @@
window.$docsify = {
loadSidebar: true,
loadNavbar: true,
loadFooter: true,
subMaxLevel: 3,
name: 'X Spring File Storage',
repo: 'https://github.com/1171736840/spring-file-storage',
name: 'X File Storage',
logo: 'https://x-file-storage.xuyanwu.cn/assets/logo2.svg',
repo: 'https://github.com/dromara/x-file-storage',
auto2top: true,
search: {
placeholder: '搜索'
Expand All @@ -43,19 +53,21 @@

</script>
<!-- Docsify v4 -->
<script src="https://spring-file-storage.xuyanwu.cn/assets/docsify.js"></script>
<script src="https://spring-file-storage.xuyanwu.cn/assets/docsify-tabs.js"></script>
<script src="https://spring-file-storage.xuyanwu.cn/assets/prism-java.min.js"></script>
<script src="https://spring-file-storage.xuyanwu.cn/assets/prism-yaml.min.js"></script>
<script src="https://spring-file-storage.xuyanwu.cn/assets/prism-sql.min.js"></script>
<script src="https://spring-file-storage.xuyanwu.cn/assets/docsify-copy-code.js"></script>
<script src="https://spring-file-storage.xuyanwu.cn/assets/docsify-pagination.min.js"></script>
<script src="https://spring-file-storage.xuyanwu.cn/assets/search.min.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/docsify.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/docsify-tabs.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/prism-java.min.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/prism-yaml.min.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/prism-sql.min.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/docsify-copy-code.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/docsify-pagination.min.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/search.min.js"></script>
<!-- https://github.com/fzankl/docsify-plugin-flexible-alerts -->
<script src="https://spring-file-storage.xuyanwu.cn/assets/docsify-plugin-flexible-alerts.js"></script>
<script src="https://spring-file-storage.xuyanwu.cn/assets/x-fold-code.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/docsify-plugin-flexible-alerts.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/x-fold-code.js"></script>
<!-- https://github.com/indieatom/docsify-puml -->
<script src="https://spring-file-storage.xuyanwu.cn/assets/docsify-puml.min.js"></script>
<script src="https://x-file-storage.xuyanwu.cn/assets/docsify-puml.min.js"></script>
<!-- https://alertbox.github.io/docsify-footer/ -->
<script src="https://x-file-storage.xuyanwu.cn/assets/docsify-footer.min.js"></script>

</body>
</html>
Loading

0 comments on commit 933683a

Please sign in to comment.