time.Hour * 24 * 7

This commit is contained in:
jiangyong27 2024-08-07 12:47:03 +08:00
parent f37bcd9878
commit ac33837a78
1 changed files with 5 additions and 0 deletions

View File

@ -112,9 +112,14 @@ func (s *Minio) Url(objectName string, expire time.Duration) string {
if err := s.Init(); err != nil { if err := s.Init(); err != nil {
return err.Error() return err.Error()
} }
if expire > time.Hour*24*7 {
expire = time.Hour * 24 * 7
}
var params url.Values var params url.Values
u, err := s.client.PresignedGetObject(s.config.Bucket, objectName, expire, params) u, err := s.client.PresignedGetObject(s.config.Bucket, objectName, expire, params)
if err != nil { if err != nil {
log.Errorf("error:%s", err.Error())
return fmt.Sprintf("%s/%s/%s", s.config.BaseUrl, s.config.Bucket, objectName) return fmt.Sprintf("%s/%s/%s", s.config.BaseUrl, s.config.Bucket, objectName)
} }