From 634fac067db89261275867674a772df38b334b19 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Wed, 3 Jul 2024 09:05:31 +0800 Subject: [PATCH 01/21] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/x/file/storage/core/get/RemoteFileInfo.java | 2 -- .../x/file/storage/core/util/KebabCaseInsensitiveMap.java | 1 - 2 files changed, 3 deletions(-) diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/get/RemoteFileInfo.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/get/RemoteFileInfo.java index f76e5e07..609ad8d4 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/get/RemoteFileInfo.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/get/RemoteFileInfo.java @@ -103,7 +103,6 @@ public class RemoteFileInfo { * 获取短横命名风格且不区分大小写的文件元数据,以下方式都获得的值相同,put进入的值也会被覆盖
* get("ContentType")
* get("Content_Type")
- * get("HelloWorld_test")
* get("Content-Type")
* get("contentType")
*/ @@ -116,7 +115,6 @@ public MapProxy getKebabCaseInsensitiveMetadata() { * 获取短横命名风格的文件用户元数据,以下方式都获得的值相同,put进入的值也会被覆盖
* get("ContentType")
* get("Content_Type")
- * get("HelloWorld_test")
* get("Content-Type")
* get("contentType")
*/ diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/util/KebabCaseInsensitiveMap.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/util/KebabCaseInsensitiveMap.java index 3b42df86..93d610d8 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/util/KebabCaseInsensitiveMap.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/util/KebabCaseInsensitiveMap.java @@ -13,7 +13,6 @@ * 对KEY转换为短横,以下方式都获得的值相同,put进入的值也会被覆盖
* get("ContentType")
* get("Content_Type")
- * get("HelloWorld_test")
* get("Content-Type")
* get("contentType")
* From 01b08474be1b33ffd670176293beb477162d3c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3i?= <1171736840@qq.com> Date: Tue, 9 Jul 2024 01:38:59 +0000 Subject: [PATCH 02/21] add .gitee/ISSUE_TEMPLATE/config.yaml. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梦想i <1171736840@qq.com> --- .gitee/ISSUE_TEMPLATE/config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .gitee/ISSUE_TEMPLATE/config.yaml diff --git a/.gitee/ISSUE_TEMPLATE/config.yaml b/.gitee/ISSUE_TEMPLATE/config.yaml new file mode 100644 index 00000000..223ab194 --- /dev/null +++ b/.gitee/ISSUE_TEMPLATE/config.yaml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: 官方文档 + url: https://x-file-storage.xuyanwu.cn/ + about: 提供使用指南、教程、功能使用、介绍和常见问题解答 + - name: 常见问题 + url: https://x-file-storage.xuyanwu.cn/#/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 + about: 提供常见问题解答 \ No newline at end of file From c8ca7974b0b02a640470089f70fad083a8265fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3i?= <1171736840@qq.com> Date: Tue, 9 Jul 2024 01:46:44 +0000 Subject: [PATCH 03/21] add .gitee/ISSUE_TEMPLATE/feature.yml. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梦想i <1171736840@qq.com> --- .gitee/ISSUE_TEMPLATE/feature.yml | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .gitee/ISSUE_TEMPLATE/feature.yml diff --git a/.gitee/ISSUE_TEMPLATE/feature.yml b/.gitee/ISSUE_TEMPLATE/feature.yml new file mode 100644 index 00000000..0f74bdda --- /dev/null +++ b/.gitee/ISSUE_TEMPLATE/feature.yml @@ -0,0 +1,43 @@ +name: 功能建议 +description: 对本项目提出一个功能建议 +title: "[功能建议]: " +labels: ["enhancement"] +body: + - type: markdown + attributes: + value: | + 感谢提出功能建议,我们将仔细考虑! + - type: textarea + id: related-problem + attributes: + label: 你的功能建议是否和某个问题相关? + description: 清晰并简洁地描述问题是什么,例如,当我...时,我总是感到困扰。 + validations: + required: false + - type: textarea + id: desired-solution + attributes: + label: 你希望看到什么解决方案? + description: 清晰并简洁地描述你希望发生的事情。 + validations: + required: true + - type: textarea + id: alternatives + attributes: + label: 你考虑过哪些替代方案? + description: 清晰并简洁地描述你考虑过的任何替代解决方案或功能。 + validations: + required: false + - type: textarea + id: additional-context + attributes: + label: 你有其他上下文或截图吗? + description: 在此处添加有关功能请求的任何其他上下文或截图。 + validations: + required: false + - type: checkboxes + attributes: + label: 意向参与贡献 + options: + - label: 我有意向参与具体功能的开发实现并将代码贡献回到上游社区 + required: false \ No newline at end of file From 15ef9ccda4e6390ee1dba530285e2dfaf1cba25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3i?= <1171736840@qq.com> Date: Tue, 9 Jul 2024 02:08:46 +0000 Subject: [PATCH 04/21] add .gitee/ISSUE_TEMPLATE/bug.yml. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梦想i <1171736840@qq.com> --- .gitee/ISSUE_TEMPLATE/bug.yml | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .gitee/ISSUE_TEMPLATE/bug.yml diff --git a/.gitee/ISSUE_TEMPLATE/bug.yml b/.gitee/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 00000000..4a82e61b --- /dev/null +++ b/.gitee/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,67 @@ +name: 问题反馈 +description: 在使用时遇到一些问题 +title: "[问题反馈]: " +labels: ["question"] +body: + - type: markdown + attributes: + value: | + 感谢对项目的支持与关注。在提出问题之前,请确保你已查看相关开发或使用文档: + - [官方文档](https://x-file-storage.xuyanwu.cn/) + - [常见问题](https://x-file-storage.xuyanwu.cn/#/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98) + - type: checkboxes + attributes: + label: 这个问题是否已经存在? + options: + - label: 我已经搜索过现有的问题 (https://gitee.com/../../issues) + required: true + - type: textarea + attributes: + label: 相关依赖及版本号 + description: 请详细输入用到的相关依赖及版本号 + placeholder: | + X File Storage 版本号: + SpringBoot 版本号: + Solon 版本号: + JVM 版本号: + 其它依赖的名称及版本号: + validations: + required: true + - type: textarea + attributes: + label: 配置文件 + description: 输入你的配置文件,IP、密钥等使用 xxx 代替 + placeholder: | + ```yaml + 在此输入配置文件 + ``` + validations: + required: true + - type: textarea + attributes: + label: 复现代码 + description: 请详细告诉我们如何复现你遇到的问题,如涉及代码,可提供一个最小代码示例,并使用反引号```附上它 + placeholder: | + 1. ... + 2. ... + 3. ... + validations: + required: true + - type: textarea + attributes: + label: 预期结果 + description: 请告诉我们你预期会发生什么。 + validations: + required: true + - type: textarea + attributes: + label: 实际结果 + description: 请告诉我们实际发生了什么。如果报错,请附上详细的报错信息 + validations: + required: true + - type: textarea + attributes: + label: 截图或视频 + description: 如果可以的话,上传任何关于 bug 的截图。 + value: | + [在这里上传图片] \ No newline at end of file From 4567508ffe4d875cb2d21ff3e1895896c121e5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3i?= <1171736840@qq.com> Date: Tue, 9 Jul 2024 02:11:17 +0000 Subject: [PATCH 05/21] update .gitee/ISSUE_TEMPLATE/bug.yml. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梦想i <1171736840@qq.com> --- .gitee/ISSUE_TEMPLATE/bug.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitee/ISSUE_TEMPLATE/bug.yml b/.gitee/ISSUE_TEMPLATE/bug.yml index 4a82e61b..a720e65c 100644 --- a/.gitee/ISSUE_TEMPLATE/bug.yml +++ b/.gitee/ISSUE_TEMPLATE/bug.yml @@ -19,7 +19,7 @@ body: attributes: label: 相关依赖及版本号 description: 请详细输入用到的相关依赖及版本号 - placeholder: | + value: | X File Storage 版本号: SpringBoot 版本号: Solon 版本号: @@ -31,9 +31,10 @@ body: attributes: label: 配置文件 description: 输入你的配置文件,IP、密钥等使用 xxx 代替 - placeholder: | + value: | ```yaml - 在此输入配置文件 + # 在此输入配置文件 + ``` validations: required: true @@ -55,8 +56,8 @@ body: required: true - type: textarea attributes: - label: 实际结果 - description: 请告诉我们实际发生了什么。如果报错,请附上详细的报错信息 + label: 实际结果或详细的报错信息 + description: 请告诉我们实际发生了什么。 validations: required: true - type: textarea From 4023b60f4647b294e3686a857cd912eda6b47d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3i?= <1171736840@qq.com> Date: Tue, 9 Jul 2024 02:11:41 +0000 Subject: [PATCH 06/21] rename .gitee/ISSUE_TEMPLATE/bug.yml to .gitee/ISSUE_TEMPLATE/question.yml. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梦想i <1171736840@qq.com> --- .gitee/ISSUE_TEMPLATE/{bug.yml => question.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .gitee/ISSUE_TEMPLATE/{bug.yml => question.yml} (100%) diff --git a/.gitee/ISSUE_TEMPLATE/bug.yml b/.gitee/ISSUE_TEMPLATE/question.yml similarity index 100% rename from .gitee/ISSUE_TEMPLATE/bug.yml rename to .gitee/ISSUE_TEMPLATE/question.yml From acdba04433ecb569012da8524375ae0e03eb58a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3i?= <1171736840@qq.com> Date: Tue, 9 Jul 2024 02:14:58 +0000 Subject: [PATCH 07/21] update .gitee/ISSUE_TEMPLATE/config.yaml. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梦想i <1171736840@qq.com> --- .gitee/ISSUE_TEMPLATE/config.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitee/ISSUE_TEMPLATE/config.yaml b/.gitee/ISSUE_TEMPLATE/config.yaml index 223ab194..45556b34 100644 --- a/.gitee/ISSUE_TEMPLATE/config.yaml +++ b/.gitee/ISSUE_TEMPLATE/config.yaml @@ -5,4 +5,7 @@ contact_links: about: 提供使用指南、教程、功能使用、介绍和常见问题解答 - name: 常见问题 url: https://x-file-storage.xuyanwu.cn/#/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 - about: 提供常见问题解答 \ No newline at end of file + about: 提供常见问题解答 + - name: 加入QQ群 515706495 + url: https://jq.qq.com/?_wv=1027&k=eGfeNqka + about: 一起交流 \ No newline at end of file From 96df7d8fc7d1644056cd61539d90204e7cbaba15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3i?= <1171736840@qq.com> Date: Tue, 9 Jul 2024 02:16:41 +0000 Subject: [PATCH 08/21] update .gitee/ISSUE_TEMPLATE/config.yaml. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梦想i <1171736840@qq.com> --- .gitee/ISSUE_TEMPLATE/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitee/ISSUE_TEMPLATE/config.yaml b/.gitee/ISSUE_TEMPLATE/config.yaml index 45556b34..2cb6a2ac 100644 --- a/.gitee/ISSUE_TEMPLATE/config.yaml +++ b/.gitee/ISSUE_TEMPLATE/config.yaml @@ -7,5 +7,5 @@ contact_links: url: https://x-file-storage.xuyanwu.cn/#/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 about: 提供常见问题解答 - name: 加入QQ群 515706495 - url: https://jq.qq.com/?_wv=1027&k=eGfeNqka + url: "https://jq.qq.com/?_wv=1027&k=eGfeNqka" about: 一起交流 \ No newline at end of file From 1623182231c235010667d31462b5cce7551aa231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3i?= <1171736840@qq.com> Date: Tue, 9 Jul 2024 02:18:57 +0000 Subject: [PATCH 09/21] update .gitee/ISSUE_TEMPLATE/config.yaml. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梦想i <1171736840@qq.com> --- .gitee/ISSUE_TEMPLATE/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitee/ISSUE_TEMPLATE/config.yaml b/.gitee/ISSUE_TEMPLATE/config.yaml index 2cb6a2ac..881d42ec 100644 --- a/.gitee/ISSUE_TEMPLATE/config.yaml +++ b/.gitee/ISSUE_TEMPLATE/config.yaml @@ -7,5 +7,5 @@ contact_links: url: https://x-file-storage.xuyanwu.cn/#/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 about: 提供常见问题解答 - name: 加入QQ群 515706495 - url: "https://jq.qq.com/?_wv=1027&k=eGfeNqka" + url: "https%3A%2F%2Fjq.qq.com%2F%3F_wv%3D1027%26k%3DeGfeNqka" about: 一起交流 \ No newline at end of file From b21285a5418b4a4fc0e0639996fdb313989d0508 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Fri, 12 Jul 2024 10:00:01 +0800 Subject: [PATCH 10/21] =?UTF-8?q?update:=E6=8F=90=E5=8D=87=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea658598..62bd78f0 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ - 2.2.0 + 2.2.1-SNAPSHOT 3.8.1 8 From bd1c577ad0a2fb6df946e670c93bad5c7f4800e2 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Fri, 12 Jul 2024 10:01:19 +0800 Subject: [PATCH 11/21] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E5=93=88=E5=B8=8C=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x/file/storage/core/InputStreamPlus.java | 4 ++-- .../core/hash/HashCalculatorManager.java | 2 ++ .../storage/core/platform/LocalFileStorage.java | 3 ++- .../core/platform/LocalPlusFileStorage.java | 3 ++- .../x-file-storage-general-test/pom.xml | 1 - .../test/controller/FileDetailController.java | 17 +++++++++++++++++ 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/InputStreamPlus.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/InputStreamPlus.java index 14f93a72..6f0a7224 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/InputStreamPlus.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/InputStreamPlus.java @@ -62,7 +62,7 @@ public long skip(long n) throws IOException { public int read() throws IOException { int b = super.read(); onProgress(b == -1 ? -1 : 1); - if (hashCalculatorManager != null && b > -1) { + if (this.markFlag == 0 && hashCalculatorManager != null && b > -1) { hashCalculatorManager.update(new byte[] {(byte) b}); } return b; @@ -72,7 +72,7 @@ public int read() throws IOException { public int read(byte[] b, int off, int len) throws IOException { onStart(); int bytes = super.read(b, off, len); - if (hashCalculatorManager != null && bytes > 0) { + if (this.markFlag == 0 && hashCalculatorManager != null && bytes > 0) { hashCalculatorManager.update(Arrays.copyOfRange(b, off, off + bytes)); } onProgress(bytes); diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java index 6af7a91d..341bad34 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java @@ -3,12 +3,14 @@ import cn.hutool.core.util.StrUtil; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; +import lombok.Getter; import org.dromara.x.file.storage.core.exception.FileStorageRuntimeException; /** * 哈希计算器管理器 */ public class HashCalculatorManager implements HashCalculatorSetter { + @Getter private final List hashCalculatorList = new CopyOnWriteArrayList<>(); private volatile HashInfo hashInfo; diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalFileStorage.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalFileStorage.java index bfab21d5..f518f43c 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalFileStorage.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalFileStorage.java @@ -79,7 +79,8 @@ public boolean save(FileInfo fileInfo, UploadPretreatment pre) { try { File newFile = FileUtil.touch(getAbsolutePath(newFileKey)); FileWrapper fileWrapper = pre.getFileWrapper(); - if (fileWrapper.supportTransfer()) { // 移动文件,速度较快 + if (fileWrapper.supportTransfer() + && pre.getHashCalculatorManager().getHashCalculatorList().isEmpty()) { // 移动文件,速度较快 ProgressListener.quickStart(pre.getProgressListener(), fileWrapper.getSize()); fileWrapper.transferTo(newFile); ProgressListener.quickFinish(pre.getProgressListener(), fileWrapper.getSize()); diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalPlusFileStorage.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalPlusFileStorage.java index 3a68065f..c69782fc 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalPlusFileStorage.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalPlusFileStorage.java @@ -65,7 +65,8 @@ public boolean save(FileInfo fileInfo, UploadPretreatment pre) { try { File newFile = FileUtil.touch(getAbsolutePath(newFileKey)); FileWrapper fileWrapper = pre.getFileWrapper(); - if (fileWrapper.supportTransfer()) { // 移动文件,速度较快 + if (fileWrapper.supportTransfer() + && pre.getHashCalculatorManager().getHashCalculatorList().isEmpty()) { // 移动文件,速度较快 ProgressListener.quickStart(pre.getProgressListener(), fileWrapper.getSize()); fileWrapper.transferTo(newFile); ProgressListener.quickFinish(pre.getProgressListener(), fileWrapper.getSize()); diff --git a/x-file-storage-tests/x-file-storage-general-test/pom.xml b/x-file-storage-tests/x-file-storage-general-test/pom.xml index 589eaba7..17fbf117 100644 --- a/x-file-storage-tests/x-file-storage-general-test/pom.xml +++ b/x-file-storage-tests/x-file-storage-general-test/pom.xml @@ -32,7 +32,6 @@ cn.hutool hutool-crypto - test com.google.guava diff --git a/x-file-storage-tests/x-file-storage-general-test/src/main/java/org/dromara/x/file/storage/test/controller/FileDetailController.java b/x-file-storage-tests/x-file-storage-general-test/src/main/java/org/dromara/x/file/storage/test/controller/FileDetailController.java index 46575613..7a72f0e8 100644 --- a/x-file-storage-tests/x-file-storage-general-test/src/main/java/org/dromara/x/file/storage/test/controller/FileDetailController.java +++ b/x-file-storage-tests/x-file-storage-general-test/src/main/java/org/dromara/x/file/storage/test/controller/FileDetailController.java @@ -1,5 +1,8 @@ package org.dromara.x.file.storage.test.controller; +import cn.hutool.core.lang.Assert; +import cn.hutool.crypto.SecureUtil; +import java.io.IOException; import java.util.Map; import javax.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; @@ -7,6 +10,7 @@ import org.dromara.x.file.storage.core.FileStorageService; import org.dromara.x.file.storage.core.file.HttpServletRequestFileWrapper; import org.dromara.x.file.storage.core.file.MultipartFormDataReader; +import org.dromara.x.file.storage.core.hash.HashInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @@ -68,4 +72,17 @@ public FileInfo uploadPlatform(HttpServletRequest request) { log.info("parameterMap:{}", parameterMap); return fileStorageService.of(wrapper).upload(); } + + /** + * 上传文件,成功返回文件 url + */ + @PostMapping("/upload-hash") + public FileInfo uploadHash(MultipartFile file) throws IOException { + FileInfo fileInfo = fileStorageService.of(file).setHashCalculatorMd5().upload(); // 将文件上传到对应地方 + + HashInfo hashInfo = fileInfo.getHashInfo(); + Assert.isTrue(SecureUtil.md5().digestHex(file.getBytes()).equals(hashInfo.getMd5()), "文件 MD5 对比不一致!"); + log.info("文件 MD5 对比通过"); + return fileInfo; + } } From c9839c4dff4ce97cf6c4ba80895ddd8d3f8f75bf Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Fri, 12 Jul 2024 16:01:19 +0800 Subject: [PATCH 12/21] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E4=B8=83=E7=89=9B?= =?UTF-8?q?=E4=BA=91=20Kodo=20=E9=A2=84=E7=AD=BE=E5=90=8D=20URL=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x/file/storage/core/platform/QiniuKodoFileStorage.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/platform/QiniuKodoFileStorage.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/QiniuKodoFileStorage.java index d3bb8676..0eacd6b5 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/QiniuKodoFileStorage.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/QiniuKodoFileStorage.java @@ -415,7 +415,7 @@ public boolean isSupportPresignedUrl() { @Override public GeneratePresignedUrlResult generatePresignedUrl(GeneratePresignedUrlPretreatment pre) { try { - if (Constant.GeneratePresignedUrl.Method.GET.equalsIgnoreCase(String.valueOf(pre.getMethod()))) { + if (!Constant.GeneratePresignedUrl.Method.GET.equalsIgnoreCase(String.valueOf(pre.getMethod()))) { throw new FileStorageRuntimeException("七牛云 Kode 仅支持 GET ,如需支持更多功能,可以通过 AWS S3 的 SDK 来使用"); } String fileKey = getFileKey(new FileInfo(basePath, pre.getPath(), pre.getFilename())); From 18f61f91d12553764e99cd15d837afa6e33e9dd5 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Fri, 12 Jul 2024 16:03:03 +0800 Subject: [PATCH 13/21] =?UTF-8?q?update:=E6=96=87=E6=A1=A3=E3=80=81?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E3=80=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...46\233\264\346\226\260\350\256\260\345\275\225.md" | 7 +++++++ .../file/storage/core/hash/HashCalculatorManager.java | 1 + .../x-file-storage-general-test/pom.xml | 3 +-- .../file/storage/test/FileStorageServiceBaseTest.java | 11 ++++++++++- 4 files changed, 19 insertions(+), 3 deletions(-) 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 a5e4573c..76a67d6b 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" @@ -2,6 +2,13 @@ ------- +## 📦2.2.1 :id=_221 +2024-07-12 +- 修复某些情况下哈希计算错误的问题 +- 修复七牛云 Kodo 预签名 URL 无法使用的问题 + +------- + ## 📦2.2.0 :id=_220 2024-07-02 - 新增获取文件 diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java index 341bad34..0fc61d94 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java @@ -12,6 +12,7 @@ public class HashCalculatorManager implements HashCalculatorSetter { @Getter private final List hashCalculatorList = new CopyOnWriteArrayList<>(); + private volatile HashInfo hashInfo; /** diff --git a/x-file-storage-tests/x-file-storage-general-test/pom.xml b/x-file-storage-tests/x-file-storage-general-test/pom.xml index 17fbf117..efbf9d08 100644 --- a/x-file-storage-tests/x-file-storage-general-test/pom.xml +++ b/x-file-storage-tests/x-file-storage-general-test/pom.xml @@ -1,6 +1,5 @@ - + 4.0.0 org.dromara.x-file-storage diff --git a/x-file-storage-tests/x-file-storage-general-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java b/x-file-storage-tests/x-file-storage-general-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java index 4d8f013f..1989c534 100644 --- a/x-file-storage-tests/x-file-storage-general-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java +++ b/x-file-storage-tests/x-file-storage-general-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java @@ -2,7 +2,9 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.IoUtil; import cn.hutool.core.lang.Assert; +import cn.hutool.crypto.SecureUtil; import java.io.InputStream; import java.util.Date; import lombok.extern.slf4j.Slf4j; @@ -32,6 +34,7 @@ public void upload() { String filename = "image.jpg"; InputStream in = this.getClass().getClassLoader().getResourceAsStream(filename); + byte[] bytes = IoUtil.readBytes(in); // 是否支持 ACL FileStorage storage = fileStorageService.getFileStorage(); @@ -39,7 +42,7 @@ public void upload() { boolean supportPresignedUrl = fileStorageService.isSupportPresignedUrl(storage); FileInfo fileInfo = fileStorageService - .of(in) + .of(bytes) .setName("file") .setOriginalFilename(filename) .setPath("test/") @@ -75,6 +78,12 @@ public void finish() { Assert.notNull(fileInfo, "文件上传失败!"); log.info("文件上传成功:{}", fileInfo.toString()); + HashInfo hashInfo = fileInfo.getHashInfo(); + Assert.isTrue(SecureUtil.md5().digestHex(bytes).equals(hashInfo.getMd5()), "文件 MD5 对比不一致!"); + log.info("文件 MD5 对比通过"); + Assert.isTrue(SecureUtil.sha256().digestHex(bytes).equals(hashInfo.getSha256()), "文件 SHA256 对比不一致!"); + log.info("文件 SHA256 对比通过"); + if (supportPresignedUrl) { String presignedUrl = fileStorageService.generatePresignedUrl(fileInfo, DateUtil.offsetHour(new Date(), 1)); System.out.println("文件授权访问地址:" + presignedUrl); From aa2db4e4642f77fda7c8409e91603cb31c3572d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E6=83=B3i?= <1171736840@qq.com> Date: Wed, 17 Jul 2024 01:39:38 +0000 Subject: [PATCH 14/21] update .gitee/ISSUE_TEMPLATE/config.yaml. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梦想i <1171736840@qq.com> --- .gitee/ISSUE_TEMPLATE/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitee/ISSUE_TEMPLATE/config.yaml b/.gitee/ISSUE_TEMPLATE/config.yaml index 881d42ec..f1af9da3 100644 --- a/.gitee/ISSUE_TEMPLATE/config.yaml +++ b/.gitee/ISSUE_TEMPLATE/config.yaml @@ -4,7 +4,7 @@ contact_links: url: https://x-file-storage.xuyanwu.cn/ about: 提供使用指南、教程、功能使用、介绍和常见问题解答 - name: 常见问题 - url: https://x-file-storage.xuyanwu.cn/#/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 + url: https%3A%2F%2Fx-file-storage.xuyanwu.cn%2F%23%2F%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98 about: 提供常见问题解答 - name: 加入QQ群 515706495 url: "https%3A%2F%2Fjq.qq.com%2F%3F_wv%3D1027%26k%3DeGfeNqka" From ec74eed559f18a1e97da49da2873037a3fd0ce8c Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Wed, 3 Jul 2024 09:05:31 +0800 Subject: [PATCH 15/21] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/dromara/x/file/storage/core/get/RemoteFileInfo.java | 2 -- .../x/file/storage/core/util/KebabCaseInsensitiveMap.java | 1 - 2 files changed, 3 deletions(-) diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/get/RemoteFileInfo.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/get/RemoteFileInfo.java index f76e5e07..609ad8d4 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/get/RemoteFileInfo.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/get/RemoteFileInfo.java @@ -103,7 +103,6 @@ public class RemoteFileInfo { * 获取短横命名风格且不区分大小写的文件元数据,以下方式都获得的值相同,put进入的值也会被覆盖
* get("ContentType")
* get("Content_Type")
- * get("HelloWorld_test")
* get("Content-Type")
* get("contentType")
*/ @@ -116,7 +115,6 @@ public MapProxy getKebabCaseInsensitiveMetadata() { * 获取短横命名风格的文件用户元数据,以下方式都获得的值相同,put进入的值也会被覆盖
* get("ContentType")
* get("Content_Type")
- * get("HelloWorld_test")
* get("Content-Type")
* get("contentType")
*/ diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/util/KebabCaseInsensitiveMap.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/util/KebabCaseInsensitiveMap.java index 3b42df86..93d610d8 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/util/KebabCaseInsensitiveMap.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/util/KebabCaseInsensitiveMap.java @@ -13,7 +13,6 @@ * 对KEY转换为短横,以下方式都获得的值相同,put进入的值也会被覆盖
* get("ContentType")
* get("Content_Type")
- * get("HelloWorld_test")
* get("Content-Type")
* get("contentType")
* From ff219a38468da1f990a79b49778b1191732af07b Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Fri, 12 Jul 2024 10:00:01 +0800 Subject: [PATCH 16/21] =?UTF-8?q?update:=E6=8F=90=E5=8D=87=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ea658598..62bd78f0 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ - 2.2.0 + 2.2.1-SNAPSHOT 3.8.1 8 From b562fe3933886a272076ab6da70b78f51b8a8046 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Fri, 12 Jul 2024 10:01:19 +0800 Subject: [PATCH 17/21] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E5=93=88=E5=B8=8C=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x/file/storage/core/InputStreamPlus.java | 4 ++-- .../core/hash/HashCalculatorManager.java | 2 ++ .../storage/core/platform/LocalFileStorage.java | 3 ++- .../core/platform/LocalPlusFileStorage.java | 3 ++- .../x-file-storage-general-test/pom.xml | 1 - .../test/controller/FileDetailController.java | 17 +++++++++++++++++ 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/InputStreamPlus.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/InputStreamPlus.java index 14f93a72..6f0a7224 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/InputStreamPlus.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/InputStreamPlus.java @@ -62,7 +62,7 @@ public long skip(long n) throws IOException { public int read() throws IOException { int b = super.read(); onProgress(b == -1 ? -1 : 1); - if (hashCalculatorManager != null && b > -1) { + if (this.markFlag == 0 && hashCalculatorManager != null && b > -1) { hashCalculatorManager.update(new byte[] {(byte) b}); } return b; @@ -72,7 +72,7 @@ public int read() throws IOException { public int read(byte[] b, int off, int len) throws IOException { onStart(); int bytes = super.read(b, off, len); - if (hashCalculatorManager != null && bytes > 0) { + if (this.markFlag == 0 && hashCalculatorManager != null && bytes > 0) { hashCalculatorManager.update(Arrays.copyOfRange(b, off, off + bytes)); } onProgress(bytes); diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java index 6af7a91d..341bad34 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java @@ -3,12 +3,14 @@ import cn.hutool.core.util.StrUtil; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; +import lombok.Getter; import org.dromara.x.file.storage.core.exception.FileStorageRuntimeException; /** * 哈希计算器管理器 */ public class HashCalculatorManager implements HashCalculatorSetter { + @Getter private final List hashCalculatorList = new CopyOnWriteArrayList<>(); private volatile HashInfo hashInfo; diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalFileStorage.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalFileStorage.java index bfab21d5..f518f43c 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalFileStorage.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalFileStorage.java @@ -79,7 +79,8 @@ public boolean save(FileInfo fileInfo, UploadPretreatment pre) { try { File newFile = FileUtil.touch(getAbsolutePath(newFileKey)); FileWrapper fileWrapper = pre.getFileWrapper(); - if (fileWrapper.supportTransfer()) { // 移动文件,速度较快 + if (fileWrapper.supportTransfer() + && pre.getHashCalculatorManager().getHashCalculatorList().isEmpty()) { // 移动文件,速度较快 ProgressListener.quickStart(pre.getProgressListener(), fileWrapper.getSize()); fileWrapper.transferTo(newFile); ProgressListener.quickFinish(pre.getProgressListener(), fileWrapper.getSize()); diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalPlusFileStorage.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalPlusFileStorage.java index 3a68065f..c69782fc 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalPlusFileStorage.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/LocalPlusFileStorage.java @@ -65,7 +65,8 @@ public boolean save(FileInfo fileInfo, UploadPretreatment pre) { try { File newFile = FileUtil.touch(getAbsolutePath(newFileKey)); FileWrapper fileWrapper = pre.getFileWrapper(); - if (fileWrapper.supportTransfer()) { // 移动文件,速度较快 + if (fileWrapper.supportTransfer() + && pre.getHashCalculatorManager().getHashCalculatorList().isEmpty()) { // 移动文件,速度较快 ProgressListener.quickStart(pre.getProgressListener(), fileWrapper.getSize()); fileWrapper.transferTo(newFile); ProgressListener.quickFinish(pre.getProgressListener(), fileWrapper.getSize()); diff --git a/x-file-storage-tests/x-file-storage-general-test/pom.xml b/x-file-storage-tests/x-file-storage-general-test/pom.xml index 589eaba7..17fbf117 100644 --- a/x-file-storage-tests/x-file-storage-general-test/pom.xml +++ b/x-file-storage-tests/x-file-storage-general-test/pom.xml @@ -32,7 +32,6 @@ cn.hutool hutool-crypto - test com.google.guava diff --git a/x-file-storage-tests/x-file-storage-general-test/src/main/java/org/dromara/x/file/storage/test/controller/FileDetailController.java b/x-file-storage-tests/x-file-storage-general-test/src/main/java/org/dromara/x/file/storage/test/controller/FileDetailController.java index 46575613..7a72f0e8 100644 --- a/x-file-storage-tests/x-file-storage-general-test/src/main/java/org/dromara/x/file/storage/test/controller/FileDetailController.java +++ b/x-file-storage-tests/x-file-storage-general-test/src/main/java/org/dromara/x/file/storage/test/controller/FileDetailController.java @@ -1,5 +1,8 @@ package org.dromara.x.file.storage.test.controller; +import cn.hutool.core.lang.Assert; +import cn.hutool.crypto.SecureUtil; +import java.io.IOException; import java.util.Map; import javax.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; @@ -7,6 +10,7 @@ import org.dromara.x.file.storage.core.FileStorageService; import org.dromara.x.file.storage.core.file.HttpServletRequestFileWrapper; import org.dromara.x.file.storage.core.file.MultipartFormDataReader; +import org.dromara.x.file.storage.core.hash.HashInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; @@ -68,4 +72,17 @@ public FileInfo uploadPlatform(HttpServletRequest request) { log.info("parameterMap:{}", parameterMap); return fileStorageService.of(wrapper).upload(); } + + /** + * 上传文件,成功返回文件 url + */ + @PostMapping("/upload-hash") + public FileInfo uploadHash(MultipartFile file) throws IOException { + FileInfo fileInfo = fileStorageService.of(file).setHashCalculatorMd5().upload(); // 将文件上传到对应地方 + + HashInfo hashInfo = fileInfo.getHashInfo(); + Assert.isTrue(SecureUtil.md5().digestHex(file.getBytes()).equals(hashInfo.getMd5()), "文件 MD5 对比不一致!"); + log.info("文件 MD5 对比通过"); + return fileInfo; + } } From 42fe3d21a2529969c477607d67775fd4e45ab2c7 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Fri, 12 Jul 2024 16:01:19 +0800 Subject: [PATCH 18/21] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E4=B8=83=E7=89=9B?= =?UTF-8?q?=E4=BA=91=20Kodo=20=E9=A2=84=E7=AD=BE=E5=90=8D=20URL=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../x/file/storage/core/platform/QiniuKodoFileStorage.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/platform/QiniuKodoFileStorage.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/QiniuKodoFileStorage.java index d3bb8676..0eacd6b5 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/QiniuKodoFileStorage.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/platform/QiniuKodoFileStorage.java @@ -415,7 +415,7 @@ public boolean isSupportPresignedUrl() { @Override public GeneratePresignedUrlResult generatePresignedUrl(GeneratePresignedUrlPretreatment pre) { try { - if (Constant.GeneratePresignedUrl.Method.GET.equalsIgnoreCase(String.valueOf(pre.getMethod()))) { + if (!Constant.GeneratePresignedUrl.Method.GET.equalsIgnoreCase(String.valueOf(pre.getMethod()))) { throw new FileStorageRuntimeException("七牛云 Kode 仅支持 GET ,如需支持更多功能,可以通过 AWS S3 的 SDK 来使用"); } String fileKey = getFileKey(new FileInfo(basePath, pre.getPath(), pre.getFilename())); From 5208b0a8134ffba64630546b3d9c5eda821845e4 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Fri, 12 Jul 2024 16:03:03 +0800 Subject: [PATCH 19/21] =?UTF-8?q?update:=E6=96=87=E6=A1=A3=E3=80=81?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E3=80=81=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...46\233\264\346\226\260\350\256\260\345\275\225.md" | 7 +++++++ .../file/storage/core/hash/HashCalculatorManager.java | 1 + .../x-file-storage-general-test/pom.xml | 3 +-- .../file/storage/test/FileStorageServiceBaseTest.java | 11 ++++++++++- 4 files changed, 19 insertions(+), 3 deletions(-) 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 a5e4573c..76a67d6b 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" @@ -2,6 +2,13 @@ ------- +## 📦2.2.1 :id=_221 +2024-07-12 +- 修复某些情况下哈希计算错误的问题 +- 修复七牛云 Kodo 预签名 URL 无法使用的问题 + +------- + ## 📦2.2.0 :id=_220 2024-07-02 - 新增获取文件 diff --git a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java index 341bad34..0fc61d94 100644 --- a/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java +++ b/x-file-storage-core/src/main/java/org/dromara/x/file/storage/core/hash/HashCalculatorManager.java @@ -12,6 +12,7 @@ public class HashCalculatorManager implements HashCalculatorSetter { @Getter private final List hashCalculatorList = new CopyOnWriteArrayList<>(); + private volatile HashInfo hashInfo; /** diff --git a/x-file-storage-tests/x-file-storage-general-test/pom.xml b/x-file-storage-tests/x-file-storage-general-test/pom.xml index 17fbf117..efbf9d08 100644 --- a/x-file-storage-tests/x-file-storage-general-test/pom.xml +++ b/x-file-storage-tests/x-file-storage-general-test/pom.xml @@ -1,6 +1,5 @@ - + 4.0.0 org.dromara.x-file-storage diff --git a/x-file-storage-tests/x-file-storage-general-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java b/x-file-storage-tests/x-file-storage-general-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java index 4d8f013f..1989c534 100644 --- a/x-file-storage-tests/x-file-storage-general-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java +++ b/x-file-storage-tests/x-file-storage-general-test/src/test/java/org/dromara/x/file/storage/test/FileStorageServiceBaseTest.java @@ -2,7 +2,9 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.IoUtil; import cn.hutool.core.lang.Assert; +import cn.hutool.crypto.SecureUtil; import java.io.InputStream; import java.util.Date; import lombok.extern.slf4j.Slf4j; @@ -32,6 +34,7 @@ public void upload() { String filename = "image.jpg"; InputStream in = this.getClass().getClassLoader().getResourceAsStream(filename); + byte[] bytes = IoUtil.readBytes(in); // 是否支持 ACL FileStorage storage = fileStorageService.getFileStorage(); @@ -39,7 +42,7 @@ public void upload() { boolean supportPresignedUrl = fileStorageService.isSupportPresignedUrl(storage); FileInfo fileInfo = fileStorageService - .of(in) + .of(bytes) .setName("file") .setOriginalFilename(filename) .setPath("test/") @@ -75,6 +78,12 @@ public void finish() { Assert.notNull(fileInfo, "文件上传失败!"); log.info("文件上传成功:{}", fileInfo.toString()); + HashInfo hashInfo = fileInfo.getHashInfo(); + Assert.isTrue(SecureUtil.md5().digestHex(bytes).equals(hashInfo.getMd5()), "文件 MD5 对比不一致!"); + log.info("文件 MD5 对比通过"); + Assert.isTrue(SecureUtil.sha256().digestHex(bytes).equals(hashInfo.getSha256()), "文件 SHA256 对比不一致!"); + log.info("文件 SHA256 对比通过"); + if (supportPresignedUrl) { String presignedUrl = fileStorageService.generatePresignedUrl(fileInfo, DateUtil.offsetHour(new Date(), 1)); System.out.println("文件授权访问地址:" + presignedUrl); From 03855a890210435232c9b56ef24a7662f04993e6 Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Thu, 18 Jul 2024 13:40:24 +0800 Subject: [PATCH 20/21] =?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 | 10 ++-------- docs/README.md | 10 ++-------- ...345\237\272\347\241\200\345\212\237\350\203\275.md" | 7 ++++--- ...345\277\253\351\200\237\345\205\245\351\227\250.md" | 7 +++++++ ...346\233\264\346\226\260\350\256\260\345\275\225.md" | 2 +- 5 files changed, 16 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 631a3c7c..a65d128e 100644 --- a/README.md +++ b/README.md @@ -56,19 +56,13 @@ Gitee:https://gitee.com/dromara/x-file-storage 这里是简要的更新记录,查看 [详细的更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录) +`2.2.1` 修复某些情况下哈希计算错误的问题、七牛云 Kodo 预签名 URL 无法使用的问题 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_221) +
`2.2.0` 修复大量问题,新增获取文件、列举文件,重构预签名 URL 支持客户端上传、下载、删除等操作,新增 Solon 插件,优化手动分片上传等功能,详情查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_220)
`2.1.0` 修复大量问题,新增存储平台 FastDFS 和 Azure Blob Storage,新增复制、移动(重命名)文件,手动分片上传(断点续传)和计算哈希等功能,详情查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_210)
`2.0.0` 捐赠至 [dromara](https://dromara.org/zh) 开源社区,更改项目名、包名,优化项目结构、支持 Metadata 元数据等,从旧版升级需要注意,详情查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_200) -
-`1.0.3` 修复了 FileStorageClientFactory 未自动加载等问题,查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_103) -
-`1.0.2` 修复了华为云 OBS 未加载的问题,查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_102) -
-`1.0.1` 修复了 MultipartFile 无法正确获取文件名等问题,查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_101) -
-`1.0.0` 包含了大量功能更新与问题修复,例如解决了内存占用过大问题,支持大文件上传、 [脱离 SpringBoot 单独使用](https://x-file-storage.xuyanwu.cn/#/脱离SpringBoot单独使用) 等,AmazonS3 和 GoogleCloudStorage 存储平台配置名称与之前版本不兼容,查看 [更新记录](https://x-file-storage.xuyanwu.cn/#/更新记录?id=_100) ------- diff --git a/docs/README.md b/docs/README.md index 101cdd2d..75be024b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -57,19 +57,13 @@ Gitee:https://gitee.com/dromara/x-file-storage 这里是简要的更新记录,查看 [详细的更新记录](更新记录) +`2.2.1` 修复某些情况下哈希计算错误的问题、七牛云 Kodo 预签名 URL 无法使用的问题 [更新记录](更新记录?id=_221) +
`2.2.0` 修复大量问题,新增获取文件、列举文件,重构预签名 URL 支持客户端上传、下载、删除等操作,新增 Solon 插件,优化手动分片上传等功能,详情查看 [更新记录](更新记录?id=_220)
`2.1.0` 修复大量问题,新增存储平台 FastDFS 和 Azure Blob Storage,新增复制、移动(重命名)文件,手动分片上传(断点续传)和计算哈希等功能,详情查看 [更新记录](更新记录?id=_210)
`2.0.0` 捐赠至 [dromara](https://dromara.org/zh) 开源社区,更改项目名、包名,优化项目结构、支持 Metadata 元数据等,从旧版升级需要注意,详情查看 [更新记录](更新记录?id=_200) -
-`1.0.3` 修复了 FileStorageClientFactory 未自动加载等问题,查看 [更新记录](更新记录?id=_103) -
-`1.0.2` 修复了华为云 OBS 未加载的问题,查看 [更新记录](更新记录?id=_102) -
-`1.0.1` 修复了 MultipartFile 无法正确获取文件名等问题,查看 [更新记录](更新记录?id=_101) -
-`1.0.0` 包含了大量功能更新与问题修复,例如解决了内存占用过大问题,支持大文件上传、 [脱离 SpringBoot 单独使用](脱离SpringBoot单独使用) 等,AmazonS3 和 GoogleCloudStorage 存储平台配置名称与之前版本不兼容,查看 [更新记录](更新记录?id=_100) ------- 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 069ebbf4..cc0e517a 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" @@ -575,9 +575,6 @@ result.getFileList().forEach(info -> log.info("文件:{}", info)); log.info("列举文件完成,共 {} 个文件", result.getFileList().size()); log.info("列举文件全部结果:{}", result); -//列表是否被截断,就是当前目录下还有其它文件或目录超出最大数量未被列举 -log.info("列表是否被截断:{}", result.getIsTruncated()); -log.info("下次列举的起始位置:{}", result.getNextMarker()); //其它更多参数 ListFilesResult result2 = fileStorageService.listFiles() @@ -586,6 +583,10 @@ ListFilesResult result2 = fileStorageService.listFiles() .setFilenamePrefix("abc") // 文件名前缀 .setMarker("123456") //列举的起始位置,从上一次列举结果中获取 .listFiles(); + +//列表是否被截断,就是当前目录下还有其它文件或目录超出最大数量未被列举 +log.info("列表是否被截断:{}", result2.getIsTruncated()); +log.info("下次列举的起始位置:{}", result2.getNextMarker()); ``` ## 下载 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 37b676d3..ff3d53b4 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" @@ -97,6 +97,13 @@ aws-java-sdk-s3 1.12.429
+ + + + com.squareup.okhttp3 + okhttp + 4.12.0 + ``` #### **FTP** 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 76a67d6b..b69d0587 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,7 +3,7 @@ ------- ## 📦2.2.1 :id=_221 -2024-07-12 +2024-07-18 - 修复某些情况下哈希计算错误的问题 - 修复七牛云 Kodo 预签名 URL 无法使用的问题 From 996c4074eb3a99b5ccde0732c4e6f4daa38759be Mon Sep 17 00:00:00 2001 From: xuyanwu <1171736840@qq.com> Date: Thu, 18 Jul 2024 13:46:42 +0800 Subject: [PATCH 21/21] Release:2.2.1 --- README.md | 2 +- "docs/\345\234\250Solon\344\270\255\344\275\277\347\224\250.md" | 2 +- "docs/\345\277\253\351\200\237\345\205\245\351\227\250.md" | 2 +- ...ringBoot\345\215\225\347\213\254\344\275\277\347\224\250.md" | 2 +- pom.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a65d128e..bf0acb8e 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Gitee:https://gitee.com/dromara/x-file-storage org.dromara.x-file-storage x-file-storage-spring - 2.2.0 + 2.2.1 diff --git "a/docs/\345\234\250Solon\344\270\255\344\275\277\347\224\250.md" "b/docs/\345\234\250Solon\344\270\255\344\275\277\347\224\250.md" index 997cac78..2e84834a 100644 --- "a/docs/\345\234\250Solon\344\270\255\344\275\277\347\224\250.md" +++ "b/docs/\345\234\250Solon\344\270\255\344\275\277\347\224\250.md" @@ -10,7 +10,7 @@ org.dromara.x-file-storage x-file-storage-solon - 2.2.0 + 2.2.1 ``` 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 ff3d53b4..4766115d 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" @@ -11,7 +11,7 @@ org.dromara.x-file-storage x-file-storage-spring - 2.2.0 + 2.2.1 ``` diff --git "a/docs/\350\204\261\347\246\273SpringBoot\345\215\225\347\213\254\344\275\277\347\224\250.md" "b/docs/\350\204\261\347\246\273SpringBoot\345\215\225\347\213\254\344\275\277\347\224\250.md" index 807f98d8..a0cf8869 100644 --- "a/docs/\350\204\261\347\246\273SpringBoot\345\215\225\347\213\254\344\275\277\347\224\250.md" +++ "b/docs/\350\204\261\347\246\273SpringBoot\345\215\225\347\213\254\344\275\277\347\224\250.md" @@ -8,7 +8,7 @@ org.dromara.x-file-storage x-file-storage-core - 2.2.0 + 2.2.1 ``` diff --git a/pom.xml b/pom.xml index 62bd78f0..8d768e3a 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ - 2.2.1-SNAPSHOT + 2.2.1 3.8.1 8