@@ -124,12 +124,7 @@ type PresignedURLOptions struct {
124124// GetPresignedURL get the object presigned to down or upload file by url
125125// 预签名函数,signHost: 默认签入Header Host, 您也可以选择不签入Header Host,但可能导致请求失败或安全漏洞
126126func (s * ObjectService ) GetPresignedURL (ctx context.Context , httpMethod , name , ak , sk string , expired time.Duration , opt interface {}, signHost ... bool ) (* url.URL , error ) {
127- // 兼容 name 以 / 开头的情况
128- if strings .HasPrefix (name , "/" ) {
129- name = encodeURIComponent ("/" ) + encodeURIComponent (name [1 :], []byte {'/' })
130- } else {
131- name = encodeURIComponent (name , []byte {'/' })
132- }
127+ name = encodeURIComponent (name )
133128
134129 sendOpt := sendOptions {
135130 baseURL : s .client .BaseURL .BucketURL ,
@@ -192,12 +187,7 @@ func (s *ObjectService) GetPresignedURL(ctx context.Context, httpMethod, name, a
192187}
193188
194189func (s * ObjectService ) GetPresignedURL2 (ctx context.Context , httpMethod , name string , expired time.Duration , opt interface {}, signHost ... bool ) (* url.URL , error ) {
195- // 兼容 name 以 / 开头的情况
196- if strings .HasPrefix (name , "/" ) {
197- name = encodeURIComponent ("/" ) + encodeURIComponent (name [1 :], []byte {'/' })
198- } else {
199- name = encodeURIComponent (name , []byte {'/' })
200- }
190+ name = encodeURIComponent (name )
201191
202192 cred := s .client .GetCredential ()
203193 if cred == nil {
@@ -271,11 +261,7 @@ func (s *ObjectService) GetPresignedURL2(ctx context.Context, httpMethod, name s
271261
272262func (s * ObjectService ) GetSignature (ctx context.Context , httpMethod , name , ak , sk string , expired time.Duration , opt * PresignedURLOptions , signHost ... bool ) string {
273263 // 兼容 name 以 / 开头的情况
274- if strings .HasPrefix (name , "/" ) {
275- name = encodeURIComponent ("/" ) + encodeURIComponent (name [1 :], []byte {'/' })
276- } else {
277- name = encodeURIComponent (name , []byte {'/' })
278- }
264+ name = encodeURIComponent (name )
279265
280266 sendOpt := sendOptions {
281267 baseURL : s .client .BaseURL .BucketURL ,
0 commit comments