diff --git a/plugin.xml b/plugin.xml index 9883cd0..11834dc 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,12 +5,13 @@ com.fanruan.fs yes no - 1.4.0 + 1.4.1 10.0~10.0 2023-03-14 richie [2023-08-08]支持分片上传,模板保存问题修复。
[2023-06-30]修复默认配置获取错误的问题,过滤有问题的路径。
[2023-03-28]第三方组件升级。
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) {