My S3 presigned URL request tries to point to AWS S3 and not localstack even when I use “test” as my aws credentials. Here is my presign request method: (Scrollable)
protected URL generatePresignedURL(String objectKey) {
S3Presigner presigner = S3Presigner.create();
GetObjectRequest objectRequest = buildGetRequest(objectKey);
GetObjectPresignRequest presignedRequest = buildPresignedGetRequest(objectRequest);
PresignedGetObjectRequest presignedGetObjectRequest =
presigner.presignGetObject(presignedRequest);
System.out.println("Presigned URL: " + presignedGetObjectRequest.url());
return presignedGetObjectRequest.url();
}
protected GetObjectRequest buildGetRequest(String objectKey) {
return GetObjectRequest.builder()
.bucket(bucketName)
.key(objectKey)
.build();
}
protected GetObjectPresignRequest buildPresignedGetRequest(GetObjectRequest objectRequest) {
// Create a GetObjectPresignRequest to specify the signature duration ( 5 minute )
return GetObjectPresignRequest.builder()
.signatureDuration(Duration.ofMinutes(5))
.getObjectRequest(objectRequest)
.build();
}
Do I need extra configuration on my presign request to explicitly point to my local instance of S3?
My upload file method works perfectly fine on my LocalStack S3 instance.
Thank you.