feat: fix the Unicode filename encoding bug in storage provider (#1518)

This commit is contained in:
wht 2023-02-04 18:09:18 +08:00 committed by GitHub
parent 8698f4111a
commit fcc75dd3be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -23,7 +23,7 @@ import (
type Resource struct {
Owner string `xorm:"varchar(100) notnull pk" json:"owner"`
Name string `xorm:"varchar(100) notnull pk" json:"name"`
Name string `xorm:"varchar(180) notnull pk" json:"name"`
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
User string `xorm:"varchar(100)" json:"user"`

View File

@ -72,8 +72,13 @@ func GetUploadFileUrl(provider *Provider, fullFilePath string, hasTimestamp bool
if provider.Type == "Azure Blob" {
host = util.UrlJoin(host, provider.Bucket)
}
fileUrl := ""
if provider.Type == "Tencent Cloud COS" {
fileUrl = util.UrlJoin(host, objectKey)
} else {
fileUrl = util.UrlJoin(host, escapePath(objectKey))
}
fileUrl := util.UrlJoin(host, escapePath(objectKey))
if hasTimestamp {
fileUrl = fmt.Sprintf("%s?t=%s", fileUrl, util.GetCurrentUnixTime())
}