mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: adapt new uploader for COS policy
This commit is contained in:
@@ -357,8 +357,9 @@ func (handler Driver) Token(ctx context.Context, ttl int64, uploadSession *seria
|
||||
|
||||
res, err := handler.getUploadCredential(ctx, postPolicy, keyTime, savePath)
|
||||
if err == nil {
|
||||
res.SessionID = uploadSession.Key
|
||||
res.Callback = apiURL
|
||||
res.Key = uploadSession.Key
|
||||
res.UploadURLs = []string{handler.Policy.Server}
|
||||
}
|
||||
|
||||
return res, err
|
||||
@@ -415,10 +416,10 @@ func (handler Driver) getUploadCredential(ctx context.Context, policy UploadPoli
|
||||
signature := hmacFinalSign.Sum(nil)
|
||||
|
||||
return &serializer.UploadCredential{
|
||||
Policy: policyEncoded,
|
||||
Path: savePath,
|
||||
AccessKey: handler.Policy.AccessKey,
|
||||
Token: fmt.Sprintf("%x", signature),
|
||||
KeyTime: keyTime,
|
||||
Policy: policyEncoded,
|
||||
Path: savePath,
|
||||
AccessKey: handler.Policy.AccessKey,
|
||||
Credential: fmt.Sprintf("%x", signature),
|
||||
KeyTime: keyTime,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -27,13 +27,12 @@ type UploadCredential struct {
|
||||
Credential string `json:"credential,omitempty"`
|
||||
UploadID string `json:"uploadID,omitempty"`
|
||||
Callback string `json:"callback,omitempty"` // 回调地址
|
||||
Path string `json:"path,omitempty"` // 存储路径
|
||||
AccessKey string `json:"ak,omitempty"`
|
||||
KeyTime string `json:"keyTime,omitempty"` // COS用有效期
|
||||
Policy string `json:"policy,omitempty"`
|
||||
|
||||
Token string `json:"token"`
|
||||
Policy string `json:"policy"`
|
||||
Path string `json:"path"` // 存储路径
|
||||
AccessKey string `json:"ak"`
|
||||
KeyTime string `json:"key_time,omitempty"` // COS用有效期
|
||||
Key string `json:"key,omitempty"` // 文件标识符,通常为回调key
|
||||
Token string `json:"token,omitempty"`
|
||||
}
|
||||
|
||||
// UploadSession 上传会话
|
||||
|
||||
Reference in New Issue
Block a user