mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-12-25 03:40:19 +01:00
Merge pull request #399 from dutchcoders/ISSUE-398
s3 and storj storage: use nil when purgeDays is 0
This commit is contained in:
commit
440ccf3a57
1 changed files with 12 additions and 2 deletions
|
@ -273,11 +273,16 @@ func (s *S3Storage) Put(token string, filename string, reader io.Reader, content
|
||||||
u.LeavePartsOnError = false
|
u.LeavePartsOnError = false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var expire *time.Time
|
||||||
|
if s.purgeDays.Hours() > 0 {
|
||||||
|
expire = aws.Time(time.Now().Add(s.purgeDays))
|
||||||
|
}
|
||||||
|
|
||||||
_, err = uploader.Upload(&s3manager.UploadInput{
|
_, err = uploader.Upload(&s3manager.UploadInput{
|
||||||
Bucket: aws.String(s.bucket),
|
Bucket: aws.String(s.bucket),
|
||||||
Key: aws.String(key),
|
Key: aws.String(key),
|
||||||
Body: reader,
|
Body: reader,
|
||||||
Expires: aws.Time(time.Now().Add(s.purgeDays)),
|
Expires: expire,
|
||||||
})
|
})
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -713,7 +718,12 @@ func (s *StorjStorage) Put(token string, filename string, reader io.Reader, cont
|
||||||
|
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
|
|
||||||
writer, err := s.project.UploadObject(ctx, s.bucket.Name, key, &uplink.UploadOptions{Expires: time.Now().Add(s.purgeDays)})
|
var uploadOptions *uplink.UploadOptions
|
||||||
|
if s.purgeDays.Hours() > 0 {
|
||||||
|
uploadOptions = &uplink.UploadOptions{Expires: time.Now().Add(s.purgeDays)}
|
||||||
|
}
|
||||||
|
|
||||||
|
writer, err := s.project.UploadObject(ctx, s.bucket.Name, key, uploadOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue