From 421e74856dd38ca8ec54acd2f060baaf57dbaa92 Mon Sep 17 00:00:00 2001 From: James Page <james@uafrica.com> Date: Thu, 18 Aug 2022 10:48:40 +0200 Subject: [PATCH] #28 Set expiry of presigned download URL to be the same as the expiry of the S3 object --- s3/s3.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/s3/s3.go b/s3/s3.go index 43edf17..3f4cafb 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -198,7 +198,11 @@ func (s SessionWithHelpers) UploadWithSettingsRevised(data []byte, bucket string } } - uploadUrl, err = s.GetSignedDownloadURL(bucket, fileName, 24*time.Hour, headers) + downloadUrlExpiry := 24 * time.Hour + if settings.ExpiryDuration != nil { + downloadUrlExpiry = *settings.ExpiryDuration + } + uploadUrl, err = s.GetSignedDownloadURL(bucket, fileName, downloadUrlExpiry, headers) if err != nil { return S3UploadResponse{}, err } -- GitLab