Skip to content

Commit 8f34e29

Browse files
authored
Merge pull request #288 from tencentyun/feature_jojoliang_02517980
Feature jojoliang 02517980
2 parents 77e05a8 + 8629280 commit 8f34e29

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ci_media.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,10 +1448,18 @@ type GetMediaInfoResult struct {
14481448
// 媒体信息接口 https://cloud.tencent.com/document/product/436/55672
14491449
func (s *CIService) GetMediaInfo(ctx context.Context, name string, opt *ObjectGetOptions, id ...string) (*GetMediaInfoResult, *Response, error) {
14501450
var u string
1451+
1452+
// 兼容 name 以 / 开头的情况
1453+
if strings.HasPrefix(name, "/") {
1454+
name = encodeURIComponent("/") + encodeURIComponent(name[1:], []byte{'/'})
1455+
} else {
1456+
name = encodeURIComponent(name, []byte{'/'})
1457+
}
1458+
14511459
if len(id) == 1 {
1452-
u = fmt.Sprintf("/%s?versionId=%s&ci-process=videoinfo", encodeURIComponent(name, []byte{'/'}), id[0])
1460+
u = fmt.Sprintf("/%s?versionId=%s&ci-process=videoinfo", name, id[0])
14531461
} else if len(id) == 0 {
1454-
u = fmt.Sprintf("/%s?ci-process=videoinfo", encodeURIComponent(name, []byte{'/'}))
1462+
u = fmt.Sprintf("/%s?ci-process=videoinfo", name)
14551463
} else {
14561464
return nil, nil, fmt.Errorf("wrong params")
14571465
}

0 commit comments

Comments
 (0)