From 7ea558189da414f7e25c9d8e09137bc98893abe7 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Mon, 16 Oct 2023 18:14:18 +0800 Subject: [PATCH 1/5] =?UTF-8?q?Update:=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- docs/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2c357e4a..0f1bf0dd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

logo
- 原名 X Spring File Storage 现已捐赠至 dromara 开源组织 + 原名 X Spring File Storage 现已捐赠至 dromara 开源组织

diff --git a/docs/README.md b/docs/README.md index a2e8f5e1..cf020b9f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@

logo
- 原名 X Spring File Storage 现已捐赠至 dromara 开源组织 + 原名 X Spring File Storage 现已捐赠至 dromara 开源组织

From 3962c69826bce9dce51f102ca40c494b30d1ea56 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Tue, 17 Oct 2023 10:07:40 +0800 Subject: [PATCH 2/5] =?UTF-8?q?Update:=E4=BC=98=E5=8C=96=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x/file/storage/core/recorder/DefaultFileRecorder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/recorder/DefaultFileRecorder.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/recorder/DefaultFileRecorder.java index bbac57f3..d69b7623 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/recorder/DefaultFileRecorder.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/recorder/DefaultFileRecorder.java @@ -19,6 +19,6 @@ public FileInfo getByUrl(String url) { @Override public boolean delete(String url) { - throw new FileStorageRuntimeException("尚未实现 FileRecorder 接口,暂时无法使用此功能,参考文档:https://x-file-storage.xuyanwu.cn/#/%E5%9F%BA%E7%A1%80%E5%8A%9F%E8%83%BD?id=%E4%BF%9D%E5%AD%98%E4%B8%8A%E4%BC%A0%E8%AE%B0%E5%BD%95"); + return true; } } From 3e5aaedaae99a6d8e27dfbbcd266dbab2e435c8d Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Tue, 17 Oct 2023 10:08:11 +0800 Subject: [PATCH 3/5] =?UTF-8?q?Update:=E4=BC=98=E5=8C=96=20FileInfo=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=93=BE=E5=BC=8F=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/dromara/x/file/storage/core/FileInfo.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/FileInfo.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/FileInfo.java index ccd36cc4..acc4b526 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/FileInfo.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/FileInfo.java @@ -3,6 +3,7 @@ import cn.hutool.core.lang.Dict; import lombok.Data; +import lombok.experimental.Accessors; import org.dromara.x.file.storage.core.constant.Constant; import java.io.Serializable; @@ -10,6 +11,7 @@ import java.util.Map; @Data +@Accessors(chain = true) public class FileInfo implements Serializable { /** From 81346e066e0649cf6b1936e865535ff9cbcd4702 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Tue, 17 Oct 2023 10:09:03 +0800 Subject: [PATCH 4/5] =?UTF-8?q?Update:=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x/file/storage/test/FileStorageServiceBaseTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-file-storage-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java b/x-file-storage-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java index c2c7a63e..c0987b22 100644 --- a/x-file-storage-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java +++ b/x-file-storage-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java @@ -210,8 +210,8 @@ public void download() { public void invoke() { FileStorage fileStorage = fileStorageService.getFileStorage(); Object[] args = new Object[]{fileStorage.getPlatform()}; - Object exists = fileStorageService.invoke(fileStorage,"setPlatform",args); - log.info("通过反射调用存储平台的方法(文件是否存在)成功,结果:{}",exists); + Object result = fileStorageService.invoke(fileStorage,"setPlatform",args); + log.info("通过反射调用存储平台的方法(文件是否存在)成功,结果:{}",result); } } From d720ba7cbf3ec5fdd6f601d4f2438e51c3cfd83f Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Tue, 17 Oct 2023 10:10:16 +0800 Subject: [PATCH 5/5] =?UTF-8?q?Update:=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 36 ++++++++++++++++- ...72\347\241\200\345\212\237\350\203\275.md" | 2 +- ...53\351\200\237\345\205\245\351\227\250.md" | 40 +++++++++++++++++-- ...64\346\226\260\350\256\260\345\275\225.md" | 3 +- 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0f1bf0dd..73abf26b 100644 --- a/README.md +++ b/README.md @@ -196,9 +196,41 @@ public class FileDetailController { } ``` -#### ⚠️重要提示 +#### 🎨其它操作 -如果想使用删除、下载等功能,请阅读 [保存上传记录](https://x-file-storage.xuyanwu.cn/#/基础功能?id=保存上传记录) 章节 +```java +//手动构造文件信息,可用于其它操作 +FileInfo fileInfo = new FileInfo() + .setPlatform("huawei-obs-1") + .setBasePath("test/") + .setPath("aa/") + .setFilename("image.png") + .setThFilename("image.png.min.jpg"); + +//文件是否存在 +boolean exists = fileStorageService.exists(fileInfo); +//下载 +byte[] bytes = fileStorageService.download(fileInfo).bytes(); +//删除 +fileStorageService.delete(fileInfo); +//其它更多操作 + +``` + +如果将文件记录保存到数据库中,还可以更方便的根据 URL 进行操作了,详情请阅读 [保存上传记录](https://x-file-storage.xuyanwu.cn/#/基础功能?id=保存上传记录) 章节 + +```java +//直接从数据库中获取 FileInfo 对象,更加方便执行其它操作 +FileInfo fileInfo = fileStorageService.getFileInfoByUrl("https://abc.def.com/test/aa/image.png"); + +//文件是否存在 +boolean exists = fileStorageService.exists("https://abc.def.com/test/aa/image.png"); +//下载 +byte[] bytes = fileStorageService.download("https://abc.def.com/test/aa/image.png").bytes(); +//删除 +fileStorageService.delete("https://abc.def.com/test/aa/image.png"); +//其它更多操作 +``` ------- diff --git "a/docs/\345\237\272\347\241\200\345\212\237\350\203\275.md" "b/docs/\345\237\272\347\241\200\345\212\237\350\203\275.md" index 2aef8984..9be2a875 100644 --- "a/docs/\345\237\272\347\241\200\345\212\237\350\203\275.md" +++ "b/docs/\345\237\272\347\241\200\345\212\237\350\203\275.md" @@ -195,7 +195,7 @@ fileStorageService.of(file).setProgressMonitor(new ProgressListener() { ## 保存上传记录 -如果还想使用除了保存文件之外的其它功能,例如删除、下载文件,还需要实现 `FileRecorder` 这个接口,把文件信息保存到数据库中。 +可以实现 `FileRecorder` 这个接口,把文件信息保存到数据库中。 ```java /** diff --git "a/docs/\345\277\253\351\200\237\345\205\245\351\227\250.md" "b/docs/\345\277\253\351\200\237\345\205\245\351\227\250.md" index 9c99ec6b..d516cf4d 100644 --- "a/docs/\345\277\253\351\200\237\345\205\245\351\227\250.md" +++ "b/docs/\345\277\253\351\200\237\345\205\245\351\227\250.md" @@ -485,8 +485,7 @@ public class SpringFileStorageTestApplication { ## 开始使用 -到此为止就可以使用上传功能了 ,如果想使用删除、下载等功能,请阅读 [保存上传记录](基础功能?id=保存上传记录) 章节 - +### 上传 支持 File、MultipartFile、byte[]、InputStream、URL、URI、String、HttpServletRequest,大文件会自动分片上传。如果想支持更多方式,请阅读 [文件适配器](文件适配器) 章节 @@ -552,5 +551,38 @@ public class FileDetailController { } ``` -> [!WARNING|label:重要提示:] -> 如果想使用删除、下载等功能,请阅读 [保存上传记录](基础功能?id=保存上传记录) 章节 +### 其它操作 + +```java +//手动构造文件信息,可用于其它操作 +FileInfo fileInfo = new FileInfo() + .setPlatform("huawei-obs-1") + .setBasePath("test/") + .setPath("aa/") + .setFilename("image.png") + .setThFilename("image.png.min.jpg"); + +//文件是否存在 +boolean exists = fileStorageService.exists(fileInfo); +//下载 +byte[] bytes = fileStorageService.download(fileInfo).bytes(); +//删除 +fileStorageService.delete(fileInfo); +//其它更多操作 + +``` + +如果将文件记录保存到数据库中,还可以更方便的根据 URL 进行操作了,详情请阅读 [保存上传记录](基础功能?id=保存上传记录) 章节 + +```java +//直接从数据库中获取 FileInfo 对象,更加方便执行其它操作 +FileInfo fileInfo = fileStorageService.getFileInfoByUrl("https://abc.def.com/test/aa/image.png"); + +//文件是否存在 +boolean exists = fileStorageService.exists("https://abc.def.com/test/aa/image.png"); +//下载 +byte[] bytes = fileStorageService.download("https://abc.def.com/test/aa/image.png").bytes(); +//删除 +fileStorageService.delete("https://abc.def.com/test/aa/image.png"); +//其它更多操作 +``` diff --git "a/docs/\346\233\264\346\226\260\350\256\260\345\275\225.md" "b/docs/\346\233\264\346\226\260\350\256\260\345\275\225.md" index ea058488..a6835f22 100644 --- "a/docs/\346\233\264\346\226\260\350\256\260\345\275\225.md" +++ "b/docs/\346\233\264\346\226\260\350\256\260\345\275\225.md" @@ -3,11 +3,12 @@ ------- ## 📦2.0.0 :id=_200 -2023-09-21 +2023-10-17 - 更改项目名、更改包名、优化项目结构 - 新增直接读取 HttpServletRequest 的流进行上传,文件不落盘,速度更快 - 新增支持 Metadata 元数据 - 优化 ACL 异常处理 +- 优化文件删除逻辑 - 修复 Amazon S3 上传文件偶现 ResetException 问题 - 捐赠至 [dromara](https://dromara.org/zh) 开源社区