use of software.amazon.awssdk.services.s3.model.EncodingType in project knime-cloud by knime.
the class S3FileSystemProvider method dirIsEmpty.
@SuppressWarnings("resource")
private static boolean dirIsEmpty(final S3Path dir) throws IOException {
final MultiRegionS3Client client = dir.getFileSystem().getClient();
final ListObjectsV2Request listRequest = //
ListObjectsV2Request.builder().bucket(//
dir.getBucketName()).prefix(//
dir.getBlobName()).delimiter(//
dir.getFileSystem().getSeparator()).encodingType(//
"url").startAfter(//
dir.getBlobName()).maxKeys(//
1).build();
try {
return client.listObjects(listRequest).keyCount() == 0;
} catch (SdkException e) {
throw AwsUtils.toIOE(e, dir);
}
}
use of software.amazon.awssdk.services.s3.model.EncodingType in project aws-sdk-java-v2 by aws.
the class DecodeUrlEncodedResponseInterceptorTest method encodingTypeNotSet_doesNotDecodeListObjectsV2ResponseParts.
@Test
public void encodingTypeNotSet_doesNotDecodeListObjectsV2ResponseParts() {
ListObjectsV2Response original = V2_TEST_ENCODED_RESPONSE.toBuilder().encodingType((String) null).build();
Context.ModifyResponse ctx = newContext(original);
ListObjectsV2Response fromInterceptor = (ListObjectsV2Response) INTERCEPTOR.modifyResponse(ctx, new ExecutionAttributes());
assertThat(fromInterceptor).isEqualTo(original);
}
use of software.amazon.awssdk.services.s3.model.EncodingType in project aws-sdk-java-v2 by aws.
the class UrlEncodingIntegrationTest method listObjectWithUrlEncodingType_shouldDecode.
@Test
public void listObjectWithUrlEncodingType_shouldDecode() {
ListObjectsResponse listObjectsV2Response = s3.listObjects(b -> b.bucket(BUCKET_NAME).encodingType(EncodingType.URL));
listObjectsV2Response.contents().forEach(c -> assertKeyIsDecoded(c.key()));
ListObjectVersionsResponse asyncResponse = s3Async.listObjectVersions(b -> b.bucket(BUCKET_NAME).encodingType(EncodingType.URL)).join();
asyncResponse.versions().forEach(v -> assertKeyIsDecoded(v.key()));
}
use of software.amazon.awssdk.services.s3.model.EncodingType in project aws-sdk-java-v2 by aws.
the class UrlEncodingIntegrationTest method listObjectVersionsWithUrlEncodingType_shouldDecode.
@Test
public void listObjectVersionsWithUrlEncodingType_shouldDecode() {
ListObjectVersionsResponse listObjectVersionsResponse = s3.listObjectVersions(b -> b.bucket(BUCKET_NAME).encodingType(EncodingType.URL));
listObjectVersionsResponse.versions().forEach(v -> assertKeyIsDecoded(v.key()));
ListObjectVersionsResponse asyncResponse = s3Async.listObjectVersions(b -> b.bucket(BUCKET_NAME).encodingType(EncodingType.URL)).join();
asyncResponse.versions().forEach(v -> assertKeyIsDecoded(v.key()));
}
use of software.amazon.awssdk.services.s3.model.EncodingType in project aws-sdk-java-v2 by aws.
the class ListObjectsIntegrationTest method listObjectsWithAllElements.
@Test
public void listObjectsWithAllElements() {
String delimiter = "/";
String marker = "aaa";
ListObjectsResponse result = s3.listObjects(ListObjectsRequest.builder().bucket(bucketName).prefix(KEY_NAME_WITH_SPECIAL_CHARS).marker(marker).encodingType(EncodingType.URL).delimiter(delimiter).build());
List<S3Object> objects = result.contents();
assertEquals(bucketName, result.name());
assertS3ObjectSummariesAreValid(objects);
assertEquals(marker, result.marker());
assertEquals(delimiter, result.delimiter());
assertEquals(KEY_NAME_WITH_SPECIAL_CHARS, result.prefix());
assertFalse(result.isTruncated());
assertTrue(result.maxKeys() >= 1000);
}
Aggregations