diff options
author | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
commit | 404aeae4545d2426c089a5f8d5e82dae56f5212b (patch) | |
tree | 2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/github.com/minio/minio-go/v7/api-copy-object.go | |
parent | 209d8b0187ed025dec9ac149ebcced3462877bff (diff) | |
download | gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip |
Make Nix builds work
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/api-copy-object.go')
-rw-r--r-- | vendor/github.com/minio/minio-go/v7/api-copy-object.go | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/api-copy-object.go b/vendor/github.com/minio/minio-go/v7/api-copy-object.go new file mode 100644 index 0000000..0c95d91 --- /dev/null +++ b/vendor/github.com/minio/minio-go/v7/api-copy-object.go | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * MinIO Go Library for Amazon S3 Compatible Cloud Storage | ||
3 | * Copyright 2017, 2018 MinIO, Inc. | ||
4 | * | ||
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | * you may not use this file except in compliance with the License. | ||
7 | * You may obtain a copy of the License at | ||
8 | * | ||
9 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | * | ||
11 | * Unless required by applicable law or agreed to in writing, software | ||
12 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | * See the License for the specific language governing permissions and | ||
15 | * limitations under the License. | ||
16 | */ | ||
17 | |||
18 | package minio | ||
19 | |||
20 | import ( | ||
21 | "context" | ||
22 | "io" | ||
23 | "net/http" | ||
24 | ) | ||
25 | |||
26 | // CopyObject - copy a source object into a new object | ||
27 | func (c *Client) CopyObject(ctx context.Context, dst CopyDestOptions, src CopySrcOptions) (UploadInfo, error) { | ||
28 | if err := src.validate(); err != nil { | ||
29 | return UploadInfo{}, err | ||
30 | } | ||
31 | |||
32 | if err := dst.validate(); err != nil { | ||
33 | return UploadInfo{}, err | ||
34 | } | ||
35 | |||
36 | header := make(http.Header) | ||
37 | dst.Marshal(header) | ||
38 | src.Marshal(header) | ||
39 | |||
40 | resp, err := c.executeMethod(ctx, http.MethodPut, requestMetadata{ | ||
41 | bucketName: dst.Bucket, | ||
42 | objectName: dst.Object, | ||
43 | customHeader: header, | ||
44 | }) | ||
45 | if err != nil { | ||
46 | return UploadInfo{}, err | ||
47 | } | ||
48 | defer closeResponse(resp) | ||
49 | |||
50 | if resp.StatusCode != http.StatusOK { | ||
51 | return UploadInfo{}, httpRespToErrorResponse(resp, dst.Bucket, dst.Object) | ||
52 | } | ||
53 | |||
54 | // Update the progress properly after successful copy. | ||
55 | if dst.Progress != nil { | ||
56 | io.Copy(io.Discard, io.LimitReader(dst.Progress, dst.Size)) | ||
57 | } | ||
58 | |||
59 | cpObjRes := copyObjectResult{} | ||
60 | if err = xmlDecoder(resp.Body, &cpObjRes); err != nil { | ||
61 | return UploadInfo{}, err | ||
62 | } | ||
63 | |||
64 | // extract lifecycle expiry date and rule ID | ||
65 | expTime, ruleID := amzExpirationToExpiryDateRuleID(resp.Header.Get(amzExpiration)) | ||
66 | |||
67 | return UploadInfo{ | ||
68 | Bucket: dst.Bucket, | ||
69 | Key: dst.Object, | ||
70 | LastModified: cpObjRes.LastModified, | ||
71 | ETag: trimEtag(resp.Header.Get("ETag")), | ||
72 | VersionID: resp.Header.Get(amzVersionID), | ||
73 | Expiration: expTime, | ||
74 | ExpirationRuleID: ruleID, | ||
75 | }, nil | ||
76 | } | ||