From 07ab867c26c410439fef19ede7c334e0cf4242af Mon Sep 17 00:00:00 2001 From: Afly 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 0466216..1a05e19 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,12 +5,13 @@ com.fanruan.fs yes no - 1.4.0 + 1.4.1 11.0~11.0 2023-03-14 richie [2023-08-08]分片上传逻辑优化,模板保存问题修复。
[2023-07-24]支持大文件分片上传。
[2023-06-30]修复默认配置获取错误的问题,过滤有问题的路径。
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 3e9455e..390dadd 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 @@ -177,7 +177,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) {