ghostrider
ghostrider

Reputation: 2238

Amazon S3 signed urls accessible from outside world

So we have a use case where we need to be able to download the S3 files from the outside world on the internet. For this we are creating s3 pre signed url as below. My doubt is how can we access this on the internet? Are these urls accessible by default on the internet. Or do we need to create a proxy.

https://<bucket-name>.s3.amazonaws.com/<filename><some other parameters>

Upvotes: 0

Views: 805

Answers (1)

smac2020
smac2020

Reputation: 10734

The URL you are showing is not a Pre-signed URL. A Pre-signed URL look like this:

https://bucketxxxxxx.s3.amazonaws.com/note.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230117T153509Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3599&X-Amz-Credential=AKIA33JWY3BX2TYWxxxxxxxxxxx%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=e55142af548e46fc2870bb03331d0e9aa9ffbd21xxxxxxxxxxxxxxxxxx

Once you generate a valid Pre-signed URL, you do not need a proxy. A user can download the object in the given time window - which you define when you create GetObjectPresignRequest .

GetObjectPresignRequest getObjectPresignRequest = GetObjectPresignRequest.builder()
                   .signatureDuration(Duration.ofMinutes(60))
                   .getObjectRequest(getObjectRequest)
                   .build();

You can see the proper way to create a pre-signed URL using AWS SDK for Java v2 in the AWS Code Github here:

https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/javav2/example_code/s3/src/main/java/com/example/s3/GetObjectPresignedUrl.java

TO read more about using the AWS SDK for Java v2 to create them, see this topic in the AWS Java V2 Developer Guide.

Working with Amazon S3 presigned URLs

Upvotes: 2

Related Questions