|
|
@ -146,14 +146,17 @@ func (o *OSS) AuthSign(ctx context.Context, uploadID string, name string, expire
|
|
|
|
if o.credentials.GetSecurityToken() != "" {
|
|
|
|
if o.credentials.GetSecurityToken() != "" {
|
|
|
|
request.Header.Set(oss.HTTPHeaderOssSecurityToken, o.credentials.GetSecurityToken())
|
|
|
|
request.Header.Set(oss.HTTPHeaderOssSecurityToken, o.credentials.GetSecurityToken())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
now := time.Now().UTC().Format(http.TimeFormat)
|
|
|
|
request.Header.Set(oss.HTTPHeaderHost, request.Host)
|
|
|
|
request.Header.Set(oss.HTTPHeaderHost, request.Host)
|
|
|
|
request.Header.Set(oss.HTTPHeaderDate, time.Now().UTC().Format(http.TimeFormat))
|
|
|
|
request.Header.Set(oss.HTTPHeaderDate, now)
|
|
|
|
|
|
|
|
request.Header.Set(oss.HttpHeaderOssDate, now)
|
|
|
|
authorization := fmt.Sprintf(
|
|
|
|
authorization := fmt.Sprintf(
|
|
|
|
`OSS %s:%s`,
|
|
|
|
`OSS %s:%s`,
|
|
|
|
o.credentials.GetAccessKeyID(),
|
|
|
|
o.credentials.GetAccessKeyID(),
|
|
|
|
o.getSignedStr(request, fmt.Sprintf(`/%s/%s?partNumber=%d&uploadId=%s`, o.bucket.BucketName, name, partNumber, uploadID), o.credentials.GetAccessKeySecret()),
|
|
|
|
o.getSignedStr(request, fmt.Sprintf(`/%s/%s?partNumber=%d&uploadId=%s`, o.bucket.BucketName, name, partNumber, uploadID), o.credentials.GetAccessKeySecret()),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
request.Header.Set(oss.HTTPHeaderAuthorization, authorization)
|
|
|
|
request.Header.Set(oss.HTTPHeaderAuthorization, authorization)
|
|
|
|
|
|
|
|
delete(request.Header, oss.HTTPHeaderDate)
|
|
|
|
result.Parts[i] = s3.SignPart{
|
|
|
|
result.Parts[i] = s3.SignPart{
|
|
|
|
PartNumber: partNumber,
|
|
|
|
PartNumber: partNumber,
|
|
|
|
Query: url.Values{"partNumber": {strconv.Itoa(partNumber)}},
|
|
|
|
Query: url.Values{"partNumber": {strconv.Itoa(partNumber)}},
|
|
|
@ -275,5 +278,5 @@ func (o *OSS) AccessURL(ctx context.Context, name string, expire time.Duration,
|
|
|
|
} else if expire < time.Second {
|
|
|
|
} else if expire < time.Second {
|
|
|
|
expire = time.Second
|
|
|
|
expire = time.Second
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return o.bucket.SignURL(name, http.MethodGet, int64(expire/time.Second))
|
|
|
|
return o.bucket.SignURL(name, http.MethodGet, int64(expire/time.Second), opts...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|