File tree Expand file tree Collapse file tree 16 files changed +355
-20
lines changed
src/main/java/cn/xuyanwu/spring/file/storage Expand file tree Collapse file tree 16 files changed +355
-20
lines changed Original file line number Diff line number Diff line change 2424
2525### 简介
2626在 SpringBoot 中通过简单的方式将文件存储到
27- 本地、FTP、SFTP、WebDAV、阿里云OSS、华为云OBS、七牛云Kodo、腾讯云COS、百度云 BOS、又拍云USS、MinIO、
27+ 本地、FTP、SFTP、WebDAV、谷歌云存储、 阿里云OSS、华为云OBS、七牛云Kodo、腾讯云COS、百度云 BOS、又拍云USS、MinIO、
2828AWS S3、金山云 KS3、美团云 MSS、京东云 OSS、天翼云 OOS、移动云 EOS、沃云 OSS、
2929网易数帆 NOS、Ucloud US3、青云 QingStor、平安云 OBS、首云 OSS、IBM COS、其它兼容 S3 协议的平台
3030
3131查看 [ 所有支持的存储平台] ( https://spring-file-storage.xuyanwu.cn/#/存储平台 )
3232
33- 后续即将支持 谷歌云存储、 Samba、NFS
33+ 后续即将支持 Samba、NFS
3434
3535> 通过 WebDAV 连接到 Alist 后,可以使用百度网盘、天翼云盘、阿里云盘、迅雷网盘等常见存储服务,[ 查看 Alist 支持的存储平台] ( https://alist-doc.nn.ci/docs/webdav )
3636
Original file line number Diff line number Diff line change 2424
2525# 简介
2626在 SpringBoot 中通过简单的方式将文件存储到
27- 本地、FTP、SFTP、WebDAV、阿里云OSS、华为云OBS、七牛云Kodo、腾讯云COS、百度云 BOS、又拍云USS、MinIO、
27+ 本地、FTP、SFTP、WebDAV、谷歌云存储、 阿里云OSS、华为云OBS、七牛云Kodo、腾讯云COS、百度云 BOS、又拍云USS、MinIO、
2828AWS S3、金山云 KS3、美团云 MSS、京东云 OSS、天翼云 OOS、移动云 EOS、沃云 OSS、
2929网易数帆 NOS、Ucloud US3、青云 QingStor、平安云 OBS、首云 OSS、IBM COS、其它兼容 S3 协议的平台
3030
3131查看 [ 所有支持的存储平台] ( 存储平台 )
3232
33- 后续即将支持 谷歌云存储、 Samba、NFS
33+ 后续即将支持 Samba、NFS
3434
3535> 通过 WebDAV 连接到 Alist 后,可以使用百度网盘、天翼云盘、阿里云盘、迅雷网盘等常见存储服务,[ 查看 Alist 支持的存储平台] ( https://alist-doc.nn.ci/docs/webdav )
3636
Original file line number Diff line number Diff line change 1- * 文档版本 0.6.1
1+ * 文档版本 0.7.0
22
3+ * [ 0.7.0] ( https://spring-file-storage.xuyanwu.cn/0.7.0/ )
34 * [ 0.6.1] ( https://spring-file-storage.xuyanwu.cn/0.6.1/ )
45 * [ 0.6.0] ( https://spring-file-storage.xuyanwu.cn/0.6.0/ )
56 * [ 0.5.0] ( https://spring-file-storage.xuyanwu.cn/0.5.0/ )
Original file line number Diff line number Diff line change 3434| 平安云 OBS | × | √ | [ 查看] ( https://yun.pingan.com/ssr/help/storage/obs/OBS_SDK_.Java_SDK_ ) |
3535| 首云 OSS | × | √ | [ 查看] ( http://www.capitalonline.net.cn/zh-cn/service/distribution/oss-new/#product-adv ) |
3636| IBM COS | × | √ | [ 查看] ( https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-compatibility-api ) |
37+ | 谷歌云存储 | √ | × | - |
3738| 其它兼容 S3 协议的平台 | × | √ | - |
3839
3940如果想通 AWS S3 SDK 使用对应的存储平台,直接将配置写在 ASW S3 中。
@@ -197,3 +198,11 @@ FileStorage myLocal = fileStorageService.getFileStorage("my-local-1");
197198list. remove(myLocal);
198199myLocal. close();// 释放资源
199200```
201+
202+ ## 获取对应存储平台
203+
204+ ``` java
205+ AliyunOssFileStorage storage = (AliyunOssFileStorage ) fileStorageService. getFileStorage(" aliyun-oss-1" );
206+ OSS client = storage. getClient();
207+ // 获取到对应SDK的原生客户端对象,可以进行更多高级操作
208+ ```
Original file line number Diff line number Diff line change 9797 <version >5.10</version >
9898 </dependency >
9999
100+ <!-- 谷歌云 Google Cloud Storage-->
101+ <dependency >
102+ <groupId >com.google.cloud</groupId >
103+ <artifactId >google-cloud-storage</artifactId >
104+ <version >2.14.0</version >
105+ </dependency >
106+
107+ <!-- 因 guava 存在较多冲突版本导致谷歌云存储无法使用,故引入独立版本-->
108+ <dependency >
109+ <groupId >com.google.guava</groupId >
110+ <artifactId >guava</artifactId >
111+ <version >31.1-jre</version >
112+ </dependency >
113+
100114</dependencies >
101115```
102116
@@ -223,6 +237,14 @@ spring:
223237 domain : ?? # 访问域名,注意“/”结尾,例如:https://file.abc.com/
224238 base-path : webdav/ # 基础路径
225239 storage-path : / # 存储路径,可以配合 Nginx 实现访问,注意“/”结尾,默认“/”
240+ google-cloud : # 谷歌云存储
241+ - platform : google-1 # 存储平台标识
242+ enable-storage : true # 启用存储
243+ project-id : ?? # 项目 id
244+ bucket-name : ??
245+ credentials-path : file:/deploy/example-key.json # 授权 key json 路径,兼容Spring的ClassPath路径、文件路径、HTTP路径等
246+ domain : ?? # 访问域名,注意“/”结尾,例如:https://storage.googleapis.com/test-bucket/
247+ base-path : hy/ # 基础路径
226248` ` `
227249
228250注意配置每个平台前面都有个` -`号,通过以下方式可以配置多个
Original file line number Diff line number Diff line change 11# 更新记录
22
3+ ## 0.7.0
4+ 2022-11-14
5+ - 增加对 谷歌云存储 的支持,由 [ kytrun] ( https://github.com/1171736840/spring-file-storage/pull/42 ) 提供,非常感谢
6+ - 修复 WebDAV 提示有误
7+ - 使用 Tika 识别 ContentType
8+
39## 0.6.1
4102022-09-05
511- 优化 ContentType 的识别方式
Original file line number Diff line number Diff line change 77 <groupId >cn.xuyanwu</groupId >
88 <artifactId >spring-file-storage-parent</artifactId >
99 <packaging >pom</packaging >
10- <version >0.6.1 </version >
10+ <version >0.7.0 </version >
1111
1212 <name >spring-file-storage-parent</name >
1313 <description >A File Storage Service</description >
Original file line number Diff line number Diff line change 1212
1313 <groupId >cn.xuyanwu</groupId >
1414 <artifactId >spring-file-storage-test</artifactId >
15- <version >0.6.1 </version >
15+ <version >0.7.0 </version >
1616 <name >spring-file-storage-test</name >
1717 <description >spring-file-storage 的测试和演示模块</description >
1818
106106 <version >3.22.3.1</version >
107107 </dependency >
108108
109+ <!-- 谷歌云 Google Cloud Platform Storage-->
110+ <dependency >
111+ <groupId >com.google.cloud</groupId >
112+ <artifactId >google-cloud-storage</artifactId >
113+ <version >2.14.0</version >
114+ </dependency >
115+
116+ <!-- 因存在较多冲突版本导致谷歌云无法使用,故引入独立版本-->
117+ <dependency >
118+ <groupId >com.google.guava</groupId >
119+ <artifactId >guava</artifactId >
120+ <version >31.1-jre</version >
121+ </dependency >
122+
109123 <!-- 糊涂工具类核心-->
110124 <dependency >
111125 <groupId >cn.hutool</groupId >
116130 <dependency >
117131 <groupId >cn.xuyanwu</groupId >
118132 <artifactId >spring-file-storage</artifactId >
119- <version >0.6.1 </version >
133+ <version >0.7.0 </version >
120134 </dependency >
121135
122136 <dependency >
Original file line number Diff line number Diff line change @@ -129,3 +129,11 @@ spring:
129129 domain : ?? # 访问域名,注意“/”结尾,例如:https://file.abc.com/
130130 base-path : webdav/ # 基础路径
131131 storage-path : / # 存储路径,上传的文件都会存储在这个路径下面,默认“/”,注意“/”结尾
132+ google-cloud : # 谷歌云存储
133+ - platform : google-1 # 存储平台标识
134+ enable-storage : true # 启用存储
135+ project-id : ?? # 项目 id
136+ bucket-name : ??
137+ credentials-path : file:/deploy/example-key.json # 授权 key json 路径,兼容Spring的ClassPath路径、文件路径、HTTP路径等
138+ domain : ?? # 访问域名,注意“/”结尾,例如:https://storage.googleapis.com/test-bucket/
139+ base-path : hy/ # 基础路径
Original file line number Diff line number Diff line change 55 <parent >
66 <artifactId >spring-file-storage-parent</artifactId >
77 <groupId >cn.xuyanwu</groupId >
8- <version >0.6.1 </version >
8+ <version >0.7.0 </version >
99 </parent >
1010 <modelVersion >4.0.0</modelVersion >
1111
1212 <artifactId >spring-file-storage</artifactId >
1313
1414 <dependencies >
1515
16+ <!-- Tika -->
17+ <dependency >
18+ <groupId >org.apache.tika</groupId >
19+ <artifactId >tika-core</artifactId >
20+ <version >2.4.1</version >
21+ </dependency >
22+
1623 <!-- WebDAV -->
1724 <dependency >
1825 <groupId >com.github.lookfirst</groupId >
127134 <optional >true</optional >
128135 </dependency >
129136
137+ <!-- 谷歌云 Google Cloud Platform Storage-->
138+ <dependency >
139+ <groupId >com.google.cloud</groupId >
140+ <artifactId >google-cloud-storage</artifactId >
141+ <version >2.14.0</version >
142+ <scope >provided</scope >
143+ <optional >true</optional >
144+ </dependency >
145+
130146 <!-- 糊涂工具类核心-->
131147 <dependency >
132148 <groupId >cn.hutool</groupId >
You can’t perform that action at this time.
0 commit comments