@@ -25,9 +25,10 @@ public class CloudStorageS3 implements TaggableCloudStorage {
2525
2626 private final AmazonS3 s3 ;
2727 private final String bucket ;
28+ private final boolean verbose ;
2829 private long preSignedUrlExpiryInSeconds = 3600 ;
2930
30- public CloudStorageS3 (String accessKeyId , String secretAccessKey , String region , String bucket , String s3Endpoint ) {
31+ public CloudStorageS3 (String accessKeyId , String secretAccessKey , String region , String bucket , String s3Endpoint , boolean verbose ) {
3132 // Reading https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html
3233 AWSCredentials creds = new BasicAWSCredentials (
3334 accessKeyId ,
@@ -45,11 +46,14 @@ public CloudStorageS3(String accessKeyId, String secretAccessKey, String region,
4546 .build ();
4647 }
4748 this .bucket = bucket ;
49+ this .verbose = verbose ;
4850 }
4951
50- public CloudStorageS3 (String region , String bucket , String s3Endpoint ) {
51- this .bucket = bucket ;
52+ public CloudStorageS3 (String accessKeyId , String secretAccessKey , String region , String bucket , String s3Endpoint ) {
53+ this (accessKeyId , secretAccessKey , region , bucket , s3Endpoint , false );
54+ }
5255
56+ public CloudStorageS3 (String region , String bucket , String s3Endpoint ) {
5357 // In theory `new InstanceProfileCredentialsProvider()` or even omitting credentials provider should work,
5458 // but for some unknown reason it doesn't. The credential it provides look realistic, but are not valid.
5559 // After a lot of experimentation and help of Abu Abraham and Isaac Wilson the only working solution we've
@@ -71,8 +75,9 @@ public CloudStorageS3(String region, String bucket, String s3Endpoint) {
7175 .withEndpointConfiguration (new AwsClientBuilder .EndpointConfiguration (s3Endpoint , region ))
7276 .enablePathStyleAccess ()
7377 .build ();
74-
7578 }
79+ this .bucket = bucket ;
80+ this .verbose = false ;
7681 }
7782
7883 @ Override
@@ -134,7 +139,7 @@ public InputStream download(String cloudPath) throws CloudStorageException {
134139 if (e .getErrorCode ().equals ("NoSuchKey" )) {
135140 throw new CloudStorageException ("The specified key does not exist: " + e .getClass ().getSimpleName () + ": " + bucket );
136141 } else {
137- throw new CloudStorageException ("s3 get error: " + e .getClass ().getSimpleName () + ": " + bucket );
142+ throw new CloudStorageException ("s3 get error: " + e .getClass ().getSimpleName () + ": " + bucket + ( verbose ? " - " + e . getMessage () : "" ) );
138143 }
139144 } catch (Throwable t ) {
140145 // Do not log the message or the original exception as that may contain the pre-signed url
0 commit comments