MCPcopy
hub / github.com/minio/minio-go / copyObjectDo

Method copyObjectDo

api-compose-object.go:254–340  ·  view source on GitHub ↗

Low level implementation of CopyObject API, supports only upto 5GiB worth of copy.

(ctx context.Context, srcBucket, srcObject, destBucket, destObject string,
	metadata map[string]string, srcOpts CopySrcOptions, dstOpts PutObjectOptions,
)

Source from the content-addressed store, hash-verified

252
253// Low level implementation of CopyObject API, supports only upto 5GiB worth of copy.
254func (c *Client) copyObjectDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject string,
255 metadata map[string]string, srcOpts CopySrcOptions, dstOpts PutObjectOptions,
256) (ObjectInfo, error) {
257 // Build headers.
258 headers := make(http.Header)
259
260 // Set all the metadata headers.
261 for k, v := range metadata {
262 headers.Set(k, v)
263 }
264 if !dstOpts.Internal.ReplicationStatus.Empty() {
265 headers.Set(amzBucketReplicationStatus, string(dstOpts.Internal.ReplicationStatus))
266 }
267 if !dstOpts.Internal.SourceMTime.IsZero() {
268 headers.Set(minIOBucketSourceMTime, dstOpts.Internal.SourceMTime.Format(time.RFC3339Nano))
269 }
270 if dstOpts.Internal.SourceETag != "" {
271 headers.Set(minIOBucketSourceETag, dstOpts.Internal.SourceETag)
272 }
273 if dstOpts.Internal.ReplicationRequest {
274 headers.Set(minIOBucketReplicationRequest, "true")
275 }
276 if dstOpts.Internal.ReplicationValidityCheck {
277 headers.Set(minIOBucketReplicationCheck, "true")
278 }
279 if !dstOpts.Internal.LegalholdTimestamp.IsZero() {
280 headers.Set(minIOBucketReplicationObjectLegalHoldTimestamp, dstOpts.Internal.LegalholdTimestamp.Format(time.RFC3339Nano))
281 }
282 if !dstOpts.Internal.RetentionTimestamp.IsZero() {
283 headers.Set(minIOBucketReplicationObjectRetentionTimestamp, dstOpts.Internal.RetentionTimestamp.Format(time.RFC3339Nano))
284 }
285 if !dstOpts.Internal.TaggingTimestamp.IsZero() {
286 headers.Set(minIOBucketReplicationTaggingTimestamp, dstOpts.Internal.TaggingTimestamp.Format(time.RFC3339Nano))
287 }
288
289 if len(dstOpts.UserTags) != 0 {
290 if tags, _ := tags.NewTags(dstOpts.UserTags, true); tags != nil {
291 headers.Set(amzTaggingHeader, tags.String())
292 }
293 }
294
295 reqMetadata := requestMetadata{
296 bucketName: destBucket,
297 objectName: destObject,
298 customHeader: headers,
299 }
300 if dstOpts.Internal.SourceVersionID != "" {
301 if dstOpts.Internal.SourceVersionID != nullVersionID {
302 if _, err := uuid.Parse(dstOpts.Internal.SourceVersionID); err != nil {
303 return ObjectInfo{}, errInvalidArgument(err.Error())
304 }
305 }
306 urlValues := make(url.Values)
307 urlValues.Set("versionId", dstOpts.Internal.SourceVersionID)
308 reqMetadata.queryValues = urlValues
309 }
310
311 // Set the source header

Callers 1

CopyObjectMethod · 0.80

Calls 10

StringMethod · 0.95
executeMethodMethod · 0.95
EncodePathFunction · 0.92
errInvalidArgumentFunction · 0.85
httpRespToErrorResponseFunction · 0.85
closeResponseFunction · 0.70
xmlDecoderFunction · 0.70
SetMethod · 0.45
EmptyMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected