|
|
@ -155,6 +155,13 @@ func (handler Driver) Put(ctx context.Context, file io.ReadCloser, dst string, s
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 决定是否要禁用文件覆盖
|
|
|
|
|
|
|
|
overwrite := "true"
|
|
|
|
|
|
|
|
if ctx.Value(fsctx.DisableOverwrite) != nil {
|
|
|
|
|
|
|
|
overwrite = "false"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 上传文件
|
|
|
|
// 上传文件
|
|
|
|
resp, err := handler.Client.Request(
|
|
|
|
resp, err := handler.Client.Request(
|
|
|
|
"POST",
|
|
|
|
"POST",
|
|
|
@ -164,6 +171,7 @@ func (handler Driver) Put(ctx context.Context, file io.ReadCloser, dst string, s
|
|
|
|
"Authorization": {credential.Token},
|
|
|
|
"Authorization": {credential.Token},
|
|
|
|
"X-Policy": {credential.Policy},
|
|
|
|
"X-Policy": {credential.Policy},
|
|
|
|
"X-FileName": {fileName},
|
|
|
|
"X-FileName": {fileName},
|
|
|
|
|
|
|
|
"X-Overwrite": {overwrite},
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
request.WithContentLength(int64(size)),
|
|
|
|
request.WithContentLength(int64(size)),
|
|
|
|
request.WithTimeout(time.Duration(0)),
|
|
|
|
request.WithTimeout(time.Duration(0)),
|
|
|
@ -321,7 +329,8 @@ func (handler Driver) getUploadCredential(ctx context.Context, policy serializer
|
|
|
|
// 签名上传策略
|
|
|
|
// 签名上传策略
|
|
|
|
uploadRequest, _ := http.NewRequest("POST", "/api/v3/slave/upload", nil)
|
|
|
|
uploadRequest, _ := http.NewRequest("POST", "/api/v3/slave/upload", nil)
|
|
|
|
uploadRequest.Header = map[string][]string{
|
|
|
|
uploadRequest.Header = map[string][]string{
|
|
|
|
"X-Policy": {policyEncoded},
|
|
|
|
"X-Policy": {policyEncoded},
|
|
|
|
|
|
|
|
"X-Overwrite": {"false"},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
auth.SignRequest(handler.AuthInstance, uploadRequest, TTL)
|
|
|
|
auth.SignRequest(handler.AuthInstance, uploadRequest, TTL)
|
|
|
|
|
|
|
|
|
|
|
|