Browse Source

REPORT-109024 fix: 小文件不使用分片上传

release/10.0
Afly 1 year ago
parent
commit
48fee39cda
  1. 3
      plugin.xml
  2. 12
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java

3
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/>

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

Loading…
Cancel
Save