Skip to content
Snippets Groups Projects
Commit a11e1ad2 authored by James Page's avatar James Page
Browse files

#26 Clarified purpose of expiry duration and added it back to `UploadWithSettings`

parent 9b254d09
No related branches found
No related tags found
1 merge request!29Resolve "Remove ExpiryDuration from S3UploadSettings"
......@@ -30,7 +30,7 @@ type S3UploadResponse struct {
type S3UploadSettings struct {
MimeType MIMEType
RetrieveSignedUrl bool
ExpiryDuration *time.Duration
ExpiryDuration *time.Duration // Used to set expiry datetime of download links. NB: does not affect deletion of object from S3 bucket.
AddContentDisposition bool
FileName string
}
......@@ -112,6 +112,12 @@ func (s SessionWithHelpers) UploadWithSettings(data []byte, bucket, fileName str
Body: bytes.NewReader(data),
}
// This sets the expiry date of the download link, not the deletion date of the object in the bucket.
if settings.ExpiryDuration != nil {
expiry := time.Now().Add(*settings.ExpiryDuration)
putInput.Expires = &expiry
}
_, err := s.S3Session.PutObject(putInput)
if err != nil {
return "", err
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment