diff --git a/plugin.xml b/plugin.xml index ae68af3..8a0e87c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -5,13 +5,14 @@ com.fanruan.fs yes no - 1.4.5 + 1.4.6 11.0~11.0 2023-03-14 richie + [2025-01-04]测试连接逻辑修改、判断虚拟目录问题修复。
+ [2024-07-25]第三方组件升级。
[2024-03-13]国际化更新
[2024-03-13]国际化更新
[2023-11-21]小文件不使用分片上传, 新增preserveMetadata后台配置。
diff --git a/src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java b/src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java index 5de506c..1fa7d52 100644 --- a/src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java +++ b/src/main/java/com/fanruan/fs/s3/repository/core/S3RepositoryFactory.java @@ -13,6 +13,8 @@ import com.fr.io.context.info.RepositoryProfile; import com.fr.io.repository.ResourceRepository; import com.fr.stable.StringUtils; +import java.util.UUID; + import static com.fanruan.fs.s3.repository.core.S3ResourceRepository.HTTP; /** @@ -59,7 +61,10 @@ public class S3RepositoryFactory extends ConfigRepositoryFactory { } amazonS3ClientBuilder = amazonS3ClientBuilder.withClientConfiguration(clientConfiguration); s3 = amazonS3ClientBuilder.build(); - s3.listObjects(config.getBucket()); + String bucket = config.getBucket(); + String testObject = "test_object_" + UUID.randomUUID(); + s3.putObject(bucket, testObject, StringUtils.EMPTY); + s3.deleteObject(bucket, testObject); } catch (Exception e) { LogKit.error(e.getMessage(), e); return false; 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 c6edea8..97e2c37 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 @@ -278,6 +278,10 @@ public class S3ResourceRepository extends BaseResourceRepository { return false; } } + return createDirectoryInternal(path); + } + + private boolean createDirectoryInternal(String path) { PutObjectRequest req = new PutObjectRequest(bucket, path, new ByteArrayInputStream(new byte[0]), buildEmptyMetadata()); try { s3.putObject(req); @@ -380,10 +384,14 @@ public class S3ResourceRepository extends BaseResourceRepository { .withBucketName(bucket) .withPrefix(path) .withDelimiter(DELIMITER)); - for (S3ObjectSummary summary : objectListing.getObjectSummaries()) { - if (summary.getKey().startsWith(path + DELIMITER)) { - return createDirectory(path); - } + String targetDir = path + DELIMITER; + if (objectListing.getCommonPrefixes().stream().anyMatch(s -> s.startsWith(targetDir))) { + createDirectoryInternal(targetDir); + return true; + } + if (objectListing.getObjectSummaries().stream().anyMatch(s -> s.getKey().startsWith(targetDir))) { + createDirectoryInternal(targetDir); + return true; } return false; } @@ -454,6 +462,7 @@ public class S3ResourceRepository extends BaseResourceRepository { } } } catch (Exception e) { + LogKit.error(e.getMessage(), e); LogKit.info("{} not exist!", path); } @@ -466,6 +475,7 @@ public class S3ResourceRepository extends BaseResourceRepository { ObjectMetadata metadata = s3.getObjectMetadata(bucket, path); return metadata.getContentLength(); } catch (Exception e) { + LogKit.error(e.getMessage(), e); LogKit.info("{} not exist!", path); }