Browse Source

Pull request #1365: 11.0.31插件改动合并

Merge in PG/plugin-repository-s3 from release/11.0 to persist/11.0

* commit 'f7ac7f6d318a3aeea75a5a4480d5045438229590':
  无jira任务 fix: 修改下preserveMetadata配置的效果
  Translated using Weblate (Korean)
  REPORT-128310 fix: 配置的项的默认值和之前保持一直
  REPORT-128310 fix: 虚拟目录识别变成一个配置项
  REPORT-117434 fix: 第三方依赖升级
  Update src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ja_JP.properties
  Translated using Weblate (Japanese)
persist/11.0
LyKay-王积凯 2 months ago
parent
commit
0f5c47c6ff
  1. BIN
      lib/ion-java-1.0.2.jar
  2. BIN
      lib/ion-java-1.11.9.jar
  3. BIN
      lib/jackson-annotations-2.14.1.jar
  4. BIN
      lib/jackson-annotations-2.17.2.jar
  5. BIN
      lib/jackson-core-2.14.1.jar
  6. BIN
      lib/jackson-core-2.17.2.jar
  7. BIN
      lib/jackson-databind-2.14.1.jar
  8. BIN
      lib/jackson-databind-2.17.2.jar
  9. BIN
      lib/jackson-dataformat-cbor-2.14.1.jar
  10. BIN
      lib/jackson-dataformat-cbor-2.17.2.jar
  11. BIN
      lib/jmespath-java-1.11.801.jar
  12. BIN
      lib/jmespath-java-1.12.762.jar
  13. 3
      plugin.xml
  14. 15
      src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java
  15. 44
      src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java
  16. 7
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ja_JP.properties
  17. 24
      src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ko_KR.properties

BIN
lib/ion-java-1.0.2.jar

Binary file not shown.

BIN
lib/ion-java-1.11.9.jar

Binary file not shown.

BIN
lib/jackson-annotations-2.14.1.jar

Binary file not shown.

BIN
lib/jackson-annotations-2.17.2.jar

Binary file not shown.

BIN
lib/jackson-core-2.14.1.jar

Binary file not shown.

BIN
lib/jackson-core-2.17.2.jar

Binary file not shown.

BIN
lib/jackson-databind-2.14.1.jar

Binary file not shown.

BIN
lib/jackson-databind-2.17.2.jar

Binary file not shown.

BIN
lib/jackson-dataformat-cbor-2.14.1.jar

Binary file not shown.

BIN
lib/jackson-dataformat-cbor-2.17.2.jar

Binary file not shown.

BIN
lib/jmespath-java-1.11.801.jar

Binary file not shown.

BIN
lib/jmespath-java-1.12.762.jar

Binary file not shown.

3
plugin.xml

@ -5,12 +5,13 @@
<main-package>com.fanruan.fs</main-package>
<active>yes</active>
<hidden>no</hidden>
<version>1.4.4</version>
<version>1.4.5</version>
<env-version>11.0~11.0</env-version>
<jartime>2023-03-14</jartime>
<vendor>richie</vendor>
<description><![CDATA[使用支持S3协议的云存储文件系统作为文件服务器。]]></description>
<change-notes><![CDATA[
[2023-07-25]第三方组件升级。 <br/>
[2024-03-13]国际化更新 <br/>
[2024-03-13]国际化更新 <br/>
[2023-11-21]小文件不使用分片上传, 新增preserveMetadata后台配置。 <br/>

15
src/main/java/com/fanruan/fs/s3/repository/core/S3Config.java

@ -44,6 +44,9 @@ public class S3Config extends CommonRepoConfig {
@Identifier("preserveMetadata")
private Conf<Boolean> preserveMetadata = HolderKit.simple(true);
@Identifier("openVirtualDirectory")
private Conf<Boolean> openVirtualDirectory = HolderKit.simple(true);
@GetConfig("endPoint")
public String getEndPoint() {
return endPoint.get();
@ -124,6 +127,16 @@ public class S3Config extends CommonRepoConfig {
this.preserveMetadata.set(preserveMetadata);
}
@GetConfig("openVirtualDirectory")
public boolean isOpenVirtualDirectory() {
return openVirtualDirectory.get();
}
@SetConfig("openVirtualDirectory")
public void setOpenVirtualDirectory(boolean openVirtualDirectory) {
this.openVirtualDirectory.set(openVirtualDirectory);
}
@Override
public void update(String key) {
super.update(key);
@ -137,6 +150,7 @@ public class S3Config extends CommonRepoConfig {
this.setSignerOverride(newConfig.getSignerOverride());
this.setMaxConnections(newConfig.getMaxConnections());
this.setPreserveMetadata(newConfig.isPreserveMetadata());
this.setOpenVirtualDirectory(newConfig.isOpenVirtualDirectory());
}
}
@ -151,6 +165,7 @@ public class S3Config extends CommonRepoConfig {
cloned.signerOverride = (Conf<String>) signerOverride.clone();
cloned.maxConnections = (Conf<Integer>) maxConnections.clone();
cloned.preserveMetadata = (Conf<Boolean>) preserveMetadata.clone();
cloned.openVirtualDirectory = (Conf<Boolean>) openVirtualDirectory.clone();
return cloned;
}
}

44
src/main/java/com/fanruan/fs/s3/repository/core/S3ResourceRepository.java

@ -59,6 +59,9 @@ public class S3ResourceRepository extends BaseResourceRepository {
private final boolean preserveMetadata;
// 是否将创建a/b/c.txt时的a/b/识别成一个存在的目录
private final boolean openVirtualDirectory;
private final AmazonS3 s3;
private final String bucket;
@ -86,6 +89,7 @@ public class S3ResourceRepository extends BaseResourceRepository {
this.s3 = amazonS3ClientBuilder.build();
this.bucket = config.getBucket();
this.preserveMetadata = config.isPreserveMetadata();
this.openVirtualDirectory = config.isOpenVirtualDirectory();
}
@Override
@ -99,6 +103,7 @@ public class S3ResourceRepository extends BaseResourceRepository {
ObjectMetadata metadata = s3.getObjectMetadata(bucket, path);
return s3Object2FileEntry(metadata, path);
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
LogKit.info("{} not exist!", path);
}
if (!path.endsWith(DELIMITER)) {
@ -170,15 +175,15 @@ public class S3ResourceRepository extends BaseResourceRepository {
metadata = s3.getObjectMetadata(bucket, path);
} catch (Exception ignore) {
}
}
if (metadata == null) {
metadata = new ObjectMetadata();
String mimeType = URLConnection.guessContentTypeFromName(path);
if (mimeType != null) {
metadata.setContentType(mimeType);
if (metadata == null) {
metadata = new ObjectMetadata();
String mimeType = URLConnection.guessContentTypeFromName(path);
if (mimeType != null) {
metadata.setContentType(mimeType);
}
}
metadata.setContentLength(length);
}
metadata.setContentLength(length);
s3.putObject(bucket, path, new ByteArrayInputStream(data), metadata);
}
}
@ -330,7 +335,16 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public boolean exist(String path) {
return fileExist(path) || (!path.endsWith(DELIMITER) && dirExist(path)) || isParentPathAbsent(path);
if (fileExist(path)) {
return true;
}
if ((!path.endsWith(DELIMITER) && dirExist(path))) {
return true;
}
if (openVirtualDirectory) {
return isVirtualDirectory(path);
}
return false;
}
private boolean fileExist(String path) {
@ -352,9 +366,9 @@ public class S3ResourceRepository extends BaseResourceRepository {
}
/**
* 如果存在文件创建了但是其父目录没有创建的场景为其递归创建对象返回创建结果
* 是否将创建对象的前缀比如a/b/c.txt时的a/b/识别成一个存在的目录.
*/
private boolean isParentPathAbsent(String path) {
private boolean isVirtualDirectory(String path) {
if (path.startsWith(DELIMITER)) {
path = path.substring(1);
}
@ -364,7 +378,8 @@ public class S3ResourceRepository extends BaseResourceRepository {
ObjectListing objectListing = s3.listObjects(
new ListObjectsRequest()
.withBucketName(bucket)
.withPrefix(path));
.withPrefix(path)
.withDelimiter(DELIMITER));
for (S3ObjectSummary summary : objectListing.getObjectSummaries()) {
if (summary.getKey().startsWith(path + DELIMITER)) {
return createDirectory(path);
@ -416,7 +431,12 @@ public class S3ResourceRepository extends BaseResourceRepository {
//是文件
return false;
} else {
return dirExist(path) || isParentPathAbsent(path);
if (dirExist(path)) {
return true;
} else {
// 是一个虚拟的目录
return openVirtualDirectory && isVirtualDirectory(path);
}
}
}

7
src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ja_JP.properties

@ -5,5 +5,8 @@ Plugin-S3_Bucket=Bucket
Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002
Plugin-S3_Region=Region
Plugin-S3_Other_Config=
Plugin-S3_EnablePathStyleAccess_Error_Tip=
Plugin-S3_Other_Config=\u3088\u308A\u591A\u304F\u306E\u8A2D\u5B9A
Plugin-S3_EnablePathStyleAccess_Error_Tip=true\u304Bfalse\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044
Plugin-Xml-I18n-S3repository_Name=S3\u30EA\u30BD\u30FC\u30B9\u30A6\u30A7\u30A2\u30CF\u30A6\u30B9
Plugin-Xml-I18n-S3repository_Change_Notes=\u0020
Plugin-Xml-I18n-S3repository_Description=\u3053\u306E\u30D7\u30E9\u30B0\u30A4\u30F3\u306F\u3001S3\u30D7\u30ED\u30C8\u30B3\u30EB\u3092\u30B5\u30DD\u30FC\u30C8\u3059\u308B\u30AF\u30E9\u30A6\u30C9\u30B9\u30C8\u30EC\u30FC\u30B8\u30D5\u30A1\u30A4\u30EB\u30B7\u30B9\u30C6\u30E0\u3092\u30D5\u30A1\u30A4\u30EB\u30B5\u30FC\u30D0\u30FC\u3068\u3057\u3066\u4F7F\u7528\u3067\u304D\u308B\u3088\u3046\u306B\u3057\u307E\u3059\u3002

24
src/main/resources/com/fanruan/fs/s3/repository/locale/s3_ko_KR.properties

@ -1,12 +1,12 @@
Dec-Error_Start_With_Slash_Or_End_Without_Slash=
Plugin-S3_Access_Key_Id=
Plugin-S3_Access_Key_Secret=
Plugin-S3_Bucket=
Plugin-S3_End_Point=
Plugin-S3_Input=
Plugin-S3_Region=
Plugin-S3_Other_Config=
Plugin-S3_EnablePathStyleAccess_Error_Tip=
Plugin-Xml-I18n-S3repository_Name=
Plugin-Xml-I18n-S3repository_Description=
Plugin-Xml-I18n-S3repository_Change_Notes=\u0020
Dec-Error_Start_With_Slash_Or_End_Without_Slash=\uACBD\uB85C\uC758 \uC2DC\uC791 \uBD80\uBD84\uC5D0 \uC2AC\uB798\uC2DC\uB97C \uAC00\uD560 \uC218 \uC5C6\uC73C\uBA70, \uBC18\uB4DC\uC2DC \uC2AC\uB798\uC2DC\uB85C \uB9C8\uBB34\uB9AC\uD574\uC57C \uD569\uB2C8\uB2E4
Plugin-S3_Access_Key_Id=AccessKeyId
Plugin-S3_Access_Key_Secret=AccessKeySecret
Plugin-S3_Bucket=Bucket
Plugin-S3_End_Point=Endpoint
Plugin-S3_Input=\uC785\uB825\uD574 \uC8FC\uC138\uC694
Plugin-S3_Region=Region
Plugin-S3_Other_Config=\uB354 \uB9CE\uC740 \uC124\uC815
Plugin-S3_EnablePathStyleAccess_Error_Tip=true \uB610\uB294 false\uB97C \uC785\uB825\uD558\uC2ED\uC2DC\uC624
Plugin-Xml-I18n-S3repository_Name=S3 \uC800\uC7A5\uC18C
Plugin-Xml-I18n-S3repository_Description=s3 \uD504\uB85C\uD1A0\uCF5C\uC744 \uC9C0\uC6D0\uD558\uB294 \uD074\uB77C\uC6B0\uB4DC \uC2A4\uD1A0\uB9AC\uC9C0 \uD30C\uC77C \uC2DC\uC2A4\uD15C\uC744 \uD30C\uC77C \uC11C\uBC84\uB85C \uC0AC\uC6A9\uD569\uB2C8\uB2E4.
Plugin-Xml-I18n-S3repository_Change_Notes=\u0020

Loading…
Cancel
Save