|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|