I'm having a bit of trouble with this code:
public boolean isExists(String key) {
try {
this.s3Client.getObjectMetadata(this.bucketName, key);
return true;
} catch (AmazonServiceException var3) {
return false;
}
}
It always returns false, even if the "folder" in S3 exists (either empty or non-empty), what could be wrong?
The s3Client
in the code above is just a simple AmazonS3 client:
AmazonS3 s3client = AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials))
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(objectStoreEndpoint, objectStoreRegion))
.build();
What's the proper way to check if folder exists in S3?