use of software.amazon.awssdk.services.s3.model.NoSuchBucketException in project aws-doc-sdk-examples by awsdocs.
the class MovieLensDatasetProvider method getObjectBytes.
// Checks to see if the dataset is already uploaded to s3.
public static boolean getObjectBytes(S3Client s3Client, String bucketName, String keyName) {
try {
GetObjectRequest objectRequest = GetObjectRequest.builder().key(keyName).bucket(bucketName).build();
ResponseBytes<GetObjectResponse> objectBytes = s3Client.getObjectAsBytes(objectRequest);
byte[] data = objectBytes.asByteArray();
return data.length > 0;
} catch (NoSuchKeyException | NoSuchBucketException ex) {
return false;
} catch (S3Exception s3Exception) {
System.err.println(s3Exception.awsErrorDetails().errorMessage());
System.exit(1);
}
return false;
}
Aggregations