|
|
@ -19,8 +19,10 @@ import com.fr.stable.Filter; |
|
|
|
import com.fr.workspace.resource.ResourceIOException; |
|
|
|
import com.fr.workspace.resource.ResourceIOException; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
import java.io.ByteArrayInputStream; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
|
|
|
|
import java.nio.file.Paths; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
@ -159,7 +161,7 @@ public class S3ResourceRepository extends BaseResourceRepository { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean exist(String path) { |
|
|
|
public boolean exist(String path) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
return s3.doesObjectExist(bucket, path); |
|
|
|
return s3.listObjectsV2(bucket, path).getKeyCount() > 0; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -175,13 +177,25 @@ public class S3ResourceRepository extends BaseResourceRepository { |
|
|
|
.withPrefix(dir).withDelimiter(DELIMITER); |
|
|
|
.withPrefix(dir).withDelimiter(DELIMITER); |
|
|
|
ObjectListing objectListing = s3.listObjects(listObjectsRequest); |
|
|
|
ObjectListing objectListing = s3.listObjects(listObjectsRequest); |
|
|
|
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { |
|
|
|
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) { |
|
|
|
if (filter.accept(objectSummary.getKey())) { |
|
|
|
String[] arr = objectSummary.getKey().split(DELIMITER); |
|
|
|
result.add(objectSummary.getKey()); |
|
|
|
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()) { |
|
|
|
for (String prefix : objectListing.getCommonPrefixes()) { |
|
|
|
if (filter.accept(prefix)) { |
|
|
|
String[] arr = prefix.split(DELIMITER); |
|
|
|
result.add(prefix); |
|
|
|
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]); |
|
|
|
return result.toArray(new String[0]); |
|
|
@ -189,11 +203,7 @@ public class S3ResourceRepository extends BaseResourceRepository { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean isDirectory(String path) { |
|
|
|
public boolean isDirectory(String path) { |
|
|
|
S3Object s3Object = s3.getObject(bucket, path); |
|
|
|
return path.endsWith(DELIMITER); |
|
|
|
if (s3Object == null) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return s3Object.getKey().endsWith("/"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|