Skip to content
Snippets Groups Projects

Resolve "Remove ExpiryDuration from S3UploadSettings"

Merged James Page requested to merge 26-remove-expiryduration-from-s3uploadsettings into main
1 file
+ 0
24
Compare changes
  • Side-by-side
  • Inline
  • 9b254d09
    #26 Remove ExpiryDuration and UploadWith1DayExpiry · 9b254d09
    James Page authored
+ 0
24
@@ -112,11 +112,6 @@ func (s SessionWithHelpers) UploadWithSettings(data []byte, bucket, fileName str
Body: bytes.NewReader(data),
}
if settings.ExpiryDuration != nil {
expiry := time.Now().Add(*settings.ExpiryDuration)
putInput.Expires = &expiry
}
_, err := s.S3Session.PutObject(putInput)
if err != nil {
return "", err
@@ -142,25 +137,6 @@ func (s SessionWithHelpers) UploadWithSettings(data []byte, bucket, fileName str
return "", nil
}
func (s SessionWithHelpers) UploadWith1DayExpiry(data []byte, bucket, fileName string, mimeType MIMEType, shouldDownloadInsteadOfOpen bool) (string, error) {
if mimeType == "" {
mimeType = getTypeForFilename(fileName)
}
expiry := 24 * time.Hour
signedUrl, err := s.UploadWithSettings(data, bucket, fileName, S3UploadSettings{
MimeType: mimeType,
RetrieveSignedUrl: true,
ExpiryDuration: &expiry,
AddContentDisposition: shouldDownloadInsteadOfOpen,
})
if err != nil {
return "", err
}
return signedUrl, nil
}
// GetSignedDownloadURL gets a signed download URL for the duration. If scv is nil, a new session will be created.
func (s SessionWithHelpers) GetSignedDownloadURL(bucket string, fileName string, duration time.Duration, headers ...map[string]string) (string, error) {
getInput := &s3.GetObjectInput{
Loading