Reputation: 12722
When one uploads an object to a S3 bucket.
Is there an API to check if the upload was successful ?
AmazonS3 amazonS3 = AmazonS3ClientBuilder.standard()
.with* ...
.build();
PutObjectResult result = this.amazonS3.putObject(s3BucketName, s3Key, file);
I read some solutions where
PS : I came from this old question How can I get upload success status with Amazon Web Services?
Upvotes: 1
Views: 3192
Reputation: 12722
OK, I created this method handling exception ( thanks to @Adam Siemion )
public boolean uploadToS3(String s3BucketName, String s3Key, File file) {
try {
this.amazonS3Client.putObject(s3BucketName, s3Key, file);
return true;
} catch (AmazonServiceException e) {
return false;
} catch (SdkClientException e) {
return false;
}
}
Amazon S3 never stores partial objects; if during this call an exception wasn't thrown, the entire object was stored.
Upvotes: 2
Reputation: 16039
Is there an API to check if the upload was successful ?
If no exception was thrown then it means it was successful.
Upvotes: 1