Reputation: 160
I'm using the AWS Java SDK within my Spring Boot app. Currently, when i want to return the URL of the s3 object i use:
s3Client.putObject(new PutObjectRequest(S3_BUCKET_NAME, key,fileToUpload));
URL signedUrl = s3Client.getUrl(S3_BUCKET_NAME, key);
And the signedUrl looks like this :
https://<my_bucket_name>.s3.eu-central-1.amazonaws.com/<my_key>
The problem is that this URL is invalid (it returns HTTPS error during connection). Right now, i cant configure my custom domain and resolve the problem via CloudFront configuration.
So my idea is to force the different format on the SDK. Something like this:
https://s3.eu-central-1.amazonaws.com/<my_bucket_name>/<my_key>
Can someone point me in the right direction?
PS: I know that, i can do a simple replace on the URL but it is not an elegant solution.
Upvotes: 1
Views: 1158
Reputation: 160
Ok, the problem was with bucket name. The dot character in bucket name was causing all the trouble.
foo-bar-com as bucket name works as expected. foo.bar.cam.s3. bucket name is causing the https exception.
Upvotes: 1