Skip to content

Commit

Permalink
Merge branch 'dev-asr-hottable' into 'master' (merge request !112)
Browse files Browse the repository at this point in the history
兼容key中包含/问题
  • Loading branch information
tencentyuncos committed Nov 18, 2024
2 parents 4fc27d6 + 233d628 commit 8629280
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ci_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -1448,10 +1448,18 @@ type GetMediaInfoResult struct {
// 媒体信息接口 https://cloud.tencent.com/document/product/436/55672
func (s *CIService) GetMediaInfo(ctx context.Context, name string, opt *ObjectGetOptions, id ...string) (*GetMediaInfoResult, *Response, error) {
var u string

// 兼容 name 以 / 开头的情况
if strings.HasPrefix(name, "/") {
name = encodeURIComponent("/") + encodeURIComponent(name[1:], []byte{'/'})
} else {
name = encodeURIComponent(name, []byte{'/'})
}

if len(id) == 1 {
u = fmt.Sprintf("/%s?versionId=%s&ci-process=videoinfo", encodeURIComponent(name, []byte{'/'}), id[0])
u = fmt.Sprintf("/%s?versionId=%s&ci-process=videoinfo", name, id[0])
} else if len(id) == 0 {
u = fmt.Sprintf("/%s?ci-process=videoinfo", encodeURIComponent(name, []byte{'/'}))
u = fmt.Sprintf("/%s?ci-process=videoinfo", name)
} else {
return nil, nil, fmt.Errorf("wrong params")
}
Expand Down

0 comments on commit 8629280

Please sign in to comment.