|
5 | 5 | "context" |
6 | 6 | "errors" |
7 | 7 | "fmt" |
8 | | - "io/ioutil" |
| 8 | + "io" |
9 | 9 | "net/http" |
10 | 10 | "net/url" |
11 | 11 | "time" |
@@ -55,7 +55,8 @@ func GetTencentCloudObjectService(bucketName string, option cloud.Option) (Objec |
55 | 55 | Transport: &cos.AuthorizationTransport{ |
56 | 56 | SecretID: option.GetSecretID(), |
57 | 57 | SecretKey: option.GetSecretKey(), |
58 | | - }}) |
| 58 | + }, |
| 59 | + }) |
59 | 60 | return &TencentCloudObjectStorageService{client: client}, nil |
60 | 61 | } |
61 | 62 |
|
@@ -136,7 +137,7 @@ func (service *TencentCloudObjectStorageService) GetObject(ctx context.Context, |
136 | 137 | } |
137 | 138 | return Object{}, err |
138 | 139 | } |
139 | | - bs, err := ioutil.ReadAll(resp.Body) |
| 140 | + bs, err := io.ReadAll(resp.Body) |
140 | 141 | if err != nil { |
141 | 142 | return Object{}, err |
142 | 143 | } |
@@ -198,13 +199,12 @@ func (service *TencentCloudObjectStorageService) PutObject(ctx context.Context, |
198 | 199 | if input == nil { |
199 | 200 | return errors.New("parameter input is nil") |
200 | 201 | } |
201 | | - var opts *cos.ObjectPutOptions |
| 202 | + opts := &cos.ObjectPutOptions{ObjectPutHeaderOptions: &cos.ObjectPutHeaderOptions{}} |
202 | 203 | if input.ContentType != "" { |
203 | | - opts = &cos.ObjectPutOptions{ |
204 | | - ObjectPutHeaderOptions: &cos.ObjectPutHeaderOptions{ |
205 | | - ContentType: input.ContentType, |
206 | | - }, |
207 | | - } |
| 204 | + opts.ContentType = input.ContentType |
| 205 | + } |
| 206 | + if input.Tagging != "" { |
| 207 | + opts.XOptionHeader = &http.Header{"x-cos-tagging": []string{input.Tagging}} |
208 | 208 | } |
209 | 209 | _, err := service.client.Object.Put(ctx, key, bytes.NewReader(input.Body), opts) |
210 | 210 | return err |
|
0 commit comments