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) {