|
|
@ -275,6 +275,7 @@ func (o *OSS) ListUploadedParts(ctx context.Context, uploadID string, name strin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (o *OSS) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
|
|
|
|
func (o *OSS) AccessURL(ctx context.Context, name string, expire time.Duration, opt *s3.AccessURLOption) (string, error) {
|
|
|
|
|
|
|
|
publicRead := config.Config.Object.Oss.PublicRead
|
|
|
|
var opts []oss.Option
|
|
|
|
var opts []oss.Option
|
|
|
|
if opt != nil {
|
|
|
|
if opt != nil {
|
|
|
|
if opt.Image != nil {
|
|
|
|
if opt.Image != nil {
|
|
|
@ -302,6 +303,7 @@ func (o *OSS) AccessURL(ctx context.Context, name string, expire time.Duration,
|
|
|
|
process += ",format," + format
|
|
|
|
process += ",format," + format
|
|
|
|
opts = append(opts, oss.Process(process))
|
|
|
|
opts = append(opts, oss.Process(process))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !publicRead {
|
|
|
|
if opt.ContentType != "" {
|
|
|
|
if opt.ContentType != "" {
|
|
|
|
opts = append(opts, oss.ResponseContentType(opt.ContentType))
|
|
|
|
opts = append(opts, oss.ResponseContentType(opt.ContentType))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -309,20 +311,19 @@ func (o *OSS) AccessURL(ctx context.Context, name string, expire time.Duration,
|
|
|
|
opts = append(opts, oss.ResponseContentDisposition(`attachment; filename=`+strconv.Quote(opt.Filename)))
|
|
|
|
opts = append(opts, oss.ResponseContentDisposition(`attachment; filename=`+strconv.Quote(opt.Filename)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if expire <= 0 {
|
|
|
|
if expire <= 0 {
|
|
|
|
expire = time.Hour * 24 * 365 * 99 // 99 years
|
|
|
|
expire = time.Hour * 24 * 365 * 99 // 99 years
|
|
|
|
} else if expire < time.Second {
|
|
|
|
} else if expire < time.Second {
|
|
|
|
expire = time.Second
|
|
|
|
expire = time.Second
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !config.Config.Object.Oss.PublicRead {
|
|
|
|
if !publicRead {
|
|
|
|
return o.bucket.SignURL(name, http.MethodGet, int64(expire/time.Second), opts...)
|
|
|
|
return o.bucket.SignURL(name, http.MethodGet, int64(expire/time.Second), opts...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rawParams, err := oss.GetRawParams(opts)
|
|
|
|
rawParams, err := oss.GetRawParams(opts)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
l := len(rawParams)
|
|
|
|
|
|
|
|
_ = l
|
|
|
|
|
|
|
|
params := getURLParams(*o.bucket.Client.Conn, rawParams)
|
|
|
|
params := getURLParams(*o.bucket.Client.Conn, rawParams)
|
|
|
|
return getURL(o.um, o.bucket.BucketName, name, params).String(), nil
|
|
|
|
return getURL(o.um, o.bucket.BucketName, name, params).String(), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|