private ObjectsResource.RewriteRequest CreateCopyObjectRequest(
            string sourceBucket,
            string sourceObjectName,
            string destinationBucket,
            string destinationObjectName,
            CopyObjectOptions options)
        {
            GaxPreconditions.CheckNotNull(sourceBucket, nameof(sourceBucket));
            GaxPreconditions.CheckNotNull(sourceObjectName, nameof(sourceObjectName));
            GaxPreconditions.CheckNotNull(destinationBucket, nameof(destinationBucket));
            GaxPreconditions.CheckNotNull(destinationObjectName, nameof(destinationObjectName));
            Object obj     = options?.ExtraMetadata ?? new Object();
            var    request = Service.Objects.Rewrite(obj, sourceBucket, sourceObjectName, destinationBucket, destinationObjectName);

            options?.ModifyRequest(request);
            ApplyEncryptionKey(options?.EncryptionKey, request);
            request.ModifyRequest += (options?.SourceEncryptionKey ?? EncryptionKey).ModifyRequestForRewriteSource;
            return(request);
        }
Exemple #2
0
        private ObjectsResource.RewriteRequest CreateCopyObjectRequest(
            string sourceBucket,
            string sourceObjectName,
            string destinationBucket,
            string destinationObjectName,
            CopyObjectOptions options)
        {
            GaxPreconditions.CheckNotNull(sourceBucket, nameof(sourceBucket));
            GaxPreconditions.CheckNotNull(sourceObjectName, nameof(sourceObjectName));
            GaxPreconditions.CheckNotNull(destinationBucket, nameof(destinationBucket));
            GaxPreconditions.CheckNotNull(destinationObjectName, nameof(destinationObjectName));
            if (destinationBucket == sourceBucket && destinationObjectName == sourceObjectName)
            {
                throw new ArgumentException("Cannot copy an object to itself. Specify either a different destination bucket or a different destination object name");
            }
            var request = Service.Objects.Rewrite(new Object(), sourceBucket, sourceObjectName, destinationBucket, destinationObjectName);

            options?.ModifyRequest(request);
            return(request);
        }