18.8.2023
Providing S3 Files with Presigned URLs
Amazon S3's default privacy setting keeps objects private, limiting access to the owner. However, sharing objects becomes easy with presigned URLs. These URLs grant temporary access using secure credentials. They can be used in browsers or programs to download objects. The URL's permissions are tied to the AWS user who generated it.
Example:
GetObjectRequest getObjectRequest = GetObjectRequest.builder()
.bucket(bucket)
.key(key)
.responseCacheControl("max-age=" + duration.getSeconds())
.responseContentType("image/png")
.build();
GetObjectPresignRequest getObjectPresignRequest = GetObjectPresignRequest.builder()
.signatureDuration(duration)
.getObjectRequest(getObjectRequest)
.build();
PresignedGetObjectRequest presignedGetObjectRequest = s3Presigner.presignGetObject(getObjectPresignRequest);
Standort Hannover
newcubator GmbH
Bödekerstraße 22
30161 Hannover
Standort Dortmund
newcubator GmbH
Westenhellweg 85-89
44137 Dortmund