diff --git a/plugin.xml b/plugin.xml
index b896706..96cd029 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -5,12 +5,13 @@
com.fanruan.fs
yes
no
- 1.1.1
+ 1.1.2
10.0
2020-01-27
richie
[2020-06-15]支持区域设置。
[2020-06-12]初始化插件。
]]>
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 ce3e3dc..f3ced78 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
@@ -19,8 +19,10 @@ import com.fr.stable.Filter;
import com.fr.workspace.resource.ResourceIOException;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.InputStream;
import java.net.URL;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@@ -159,7 +161,7 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public boolean exist(String path) {
try {
- return s3.doesObjectExist(bucket, path);
+ return s3.listObjectsV2(bucket, path).getKeyCount() > 0;
} catch (Exception e) {
return false;
}
@@ -175,13 +177,25 @@ public class S3ResourceRepository extends BaseResourceRepository {
.withPrefix(dir).withDelimiter(DELIMITER);
ObjectListing objectListing = s3.listObjects(listObjectsRequest);
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
- if (filter.accept(objectSummary.getKey())) {
- result.add(objectSummary.getKey());
+ String[] arr = objectSummary.getKey().split(DELIMITER);
+ String name = arr[arr.length - 1];
+ if (filter == null) {
+ result.add(name);
+ } else {
+ if (filter.accept(name)) {
+ result.add(name);
+ }
}
}
for (String prefix : objectListing.getCommonPrefixes()) {
- if (filter.accept(prefix)) {
- result.add(prefix);
+ String[] arr = prefix.split(DELIMITER);
+ String name = arr[arr.length - 1] + DELIMITER;
+ if (filter == null) {
+ result.add(name);
+ } else {
+ if (filter.accept(name)) {
+ result.add(name);
+ }
}
}
return result.toArray(new String[0]);
@@ -189,11 +203,7 @@ public class S3ResourceRepository extends BaseResourceRepository {
@Override
public boolean isDirectory(String path) {
- S3Object s3Object = s3.getObject(bucket, path);
- if (s3Object == null) {
- return false;
- }
- return s3Object.getKey().endsWith("/");
+ return path.endsWith(DELIMITER);
}
@Override