From 48fee39cda012170295cfacdb46210b0a3901c72 Mon Sep 17 00:00:00 2001 From: Afly <Afly@fanruan.com> Date: Tue, 21 Nov 2023 10:32:54 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-109024=20fix:=20=E5=B0=8F=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E4=BD=BF=E7=94=A8=E5=88=86=E7=89=87=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.xml | 3 ++- .../s3/repository/core/S3ResourceRepository.java | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugin.xml b/plugin.xml index 9883cd0..11834dc 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,12 +5,13 @@ <main-package>com.fanruan.fs</main-package> <active>yes</active> <hidden>no</hidden> - <version>1.4.0</version> + <version>1.4.1</version> <env-version>10.0~10.0</env-version> <jartime>2023-03-14</jartime> <vendor>richie</vendor> <description><![CDATA[使用支持S3协议的云存储文件系统作为文件服务器。]]></description> <change-notes><![CDATA[ + [2023-11-21]小文件不使用分片上传。 <br/> [2023-08-08]支持分片上传,模板保存问题修复。 <br/> [2023-06-30]修复默认配置获取错误的问题,过滤有问题的路径。 <br/> [2023-03-28]第三方组件升级。 <br/> diff --git a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java index f82d7ad..b0a8f7b 100644 --- a/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java +++ b/src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java @@ -176,7 +176,19 @@ public class S3ResourceRepository extends BaseResourceRepository { @Override public void write(String path, InputStream inputStream) throws ResourceIOException { - multipartUpload(path, inputStream); + long dataLength = 0; + try { + dataLength = inputStream.available(); + } catch (IOException e) { + LogKit.error(e.getMessage(), e); + } + //超过一定大小才使用分片上传,小文件来说,网络传输时间可能较短,且上传失败的风险相对较低。 + //在网络稳定的情况下,使用分片上传可能没有太多的优势,反而增加了额外开销和复杂性 + if (dataLength > MULTIPART_UPLOAD_LIMIT) { + multipartUpload(path, inputStream); + } else { + super.write(path, inputStream); + } } private void multipartUpload(String path, InputStream inputStream) {