Ejemplo n.º 1
0
        public IRequest Marshall(InitiateMultipartUploadRequest initiateMultipartUploadRequest)
        {
            //IL_0006: Unknown result type (might be due to invalid IL or missing references)
            //IL_000c: Expected O, but got Unknown
            IRequest val = new DefaultRequest(initiateMultipartUploadRequest, "AmazonS3");

            val.set_HttpMethod("POST");
            if (initiateMultipartUploadRequest.IsSetCannedACL())
            {
                val.get_Headers().Add("x-amz-acl", S3Transforms.ToStringValue(ConstantClass.op_Implicit(initiateMultipartUploadRequest.CannedACL)));
            }
            HeadersCollection headers = initiateMultipartUploadRequest.Headers;

            foreach (string key in headers.Keys)
            {
                val.get_Headers().Add(key, headers[key]);
            }
            HeaderACLRequestMarshaller.Marshall(val, initiateMultipartUploadRequest);
            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption", S3Transforms.ToStringValue(ConstantClass.op_Implicit(initiateMultipartUploadRequest.ServerSideEncryptionMethod)));
            }
            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-algorithm", ConstantClass.op_Implicit(initiateMultipartUploadRequest.ServerSideEncryptionCustomerMethod));
            }
            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-key", initiateMultipartUploadRequest.ServerSideEncryptionCustomerProvidedKey);
                if (initiateMultipartUploadRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", initiateMultipartUploadRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", AmazonS3Util.ComputeEncodedMD5FromEncodedString(initiateMultipartUploadRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionKeyManagementServiceKeyId())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-aws-kms-key-id", initiateMultipartUploadRequest.ServerSideEncryptionKeyManagementServiceKeyId);
            }
            if (initiateMultipartUploadRequest.IsSetStorageClass())
            {
                val.get_Headers().Add("x-amz-storage-class", S3Transforms.ToStringValue(ConstantClass.op_Implicit(initiateMultipartUploadRequest.StorageClass)));
            }
            if (initiateMultipartUploadRequest.IsSetWebsiteRedirectLocation())
            {
                val.get_Headers().Add("x-amz-website-redirect-location", S3Transforms.ToStringValue(initiateMultipartUploadRequest.WebsiteRedirectLocation));
            }
            if (initiateMultipartUploadRequest.IsSetRequestPayer())
            {
                val.get_Headers().Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(((object)initiateMultipartUploadRequest.RequestPayer).ToString()));
            }
            AmazonS3Util.SetMetadataHeaders(val, initiateMultipartUploadRequest.Metadata);
            val.set_ResourcePath(string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(initiateMultipartUploadRequest.BucketName), S3Transforms.ToStringValue(initiateMultipartUploadRequest.Key)));
            val.AddSubResource("uploads");
            val.set_UseQueryString(true);
            return(val);
        }
Ejemplo n.º 2
0
        public IRequest Marshall(InitiateMultipartUploadRequest initiateMultipartUploadRequest)
        {
            IRequest request = new DefaultRequest(initiateMultipartUploadRequest, "AmazonS3");

            request.HttpMethod = "POST";

            if (initiateMultipartUploadRequest.IsSetCannedACL())
            {
                request.Headers.Add("x-amz-acl", S3Transforms.ToStringValue(initiateMultipartUploadRequest.CannedACL));
            }

            var headers = initiateMultipartUploadRequest.Headers;

            foreach (var key in headers.Keys)
            {
                request.Headers.Add(key, headers[key]);
            }

            HeaderACLRequestMarshaller.Marshall(request, initiateMultipartUploadRequest);

            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers.Add("x-amz-server-side-encryption", S3Transforms.ToStringValue(initiateMultipartUploadRequest.ServerSideEncryptionMethod));
            }

            if (initiateMultipartUploadRequest.IsSetStorageClass())
            {
                request.Headers.Add("x-amz-storage-class", S3Transforms.ToStringValue(initiateMultipartUploadRequest.StorageClass));
            }

            if (initiateMultipartUploadRequest.IsSetWebsiteRedirectLocation())
            {
                request.Headers.Add("x-amz-website-redirect-location", S3Transforms.ToStringValue(initiateMultipartUploadRequest.WebsiteRedirectLocation));
            }

            AmazonS3Util.SetMetadataHeaders(request, initiateMultipartUploadRequest.Metadata);

            var uriResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}",
                                                S3Transforms.ToStringValue(initiateMultipartUploadRequest.BucketName),
                                                S3Transforms.ToStringValue(initiateMultipartUploadRequest.Key));

            request.Parameters.Add("uploads", null);

            request.CanonicalResource = S3Transforms.GetCanonicalResource(uriResourcePath, request.Parameters);
            request.ResourcePath      = S3Transforms.FormatResourcePath(uriResourcePath, request.Parameters);
            request.UseQueryString    = true;

            return(request);
        }
        public IRequest Marshall(InitiateMultipartUploadRequest initiateMultipartUploadRequest)
        {
            IRequest request = new DefaultRequest(initiateMultipartUploadRequest, "AmazonS3");

            request.HttpMethod = "POST";

            if (initiateMultipartUploadRequest.IsSetCannedACL())
            {
                request.Headers.Add(HeaderKeys.XAmzAclHeader, S3Transforms.ToStringValue(initiateMultipartUploadRequest.CannedACL));
            }

            var headers = initiateMultipartUploadRequest.Headers;

            foreach (var key in headers.Keys)
            {
                request.Headers.Add(key, headers[key]);
            }

            HeaderACLRequestMarshaller.Marshall(request, initiateMultipartUploadRequest);

            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionHeader, S3Transforms.ToStringValue(initiateMultipartUploadRequest.ServerSideEncryptionMethod));
            }
            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, initiateMultipartUploadRequest.ServerSideEncryptionCustomerMethod);
            }
            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, initiateMultipartUploadRequest.ServerSideEncryptionCustomerProvidedKey);
                if (initiateMultipartUploadRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, initiateMultipartUploadRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(initiateMultipartUploadRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }

            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionKeyManagementServiceKeyId())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionAwsKmsKeyIdHeader, initiateMultipartUploadRequest.ServerSideEncryptionKeyManagementServiceKeyId);
            }

            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionKeyManagementServiceEncryptionContext())
            {
                request.Headers.Add("x-amz-server-side-encryption-context", initiateMultipartUploadRequest.ServerSideEncryptionKeyManagementServiceEncryptionContext);
            }

            if (initiateMultipartUploadRequest.IsSetStorageClass())
            {
                request.Headers.Add(HeaderKeys.XAmzStorageClassHeader, S3Transforms.ToStringValue(initiateMultipartUploadRequest.StorageClass));
            }

            if (initiateMultipartUploadRequest.IsSetWebsiteRedirectLocation())
            {
                request.Headers.Add(HeaderKeys.XAmzWebsiteRedirectLocationHeader, S3Transforms.ToStringValue(initiateMultipartUploadRequest.WebsiteRedirectLocation));
            }
            if (initiateMultipartUploadRequest.IsSetRequestPayer())
            {
                request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(initiateMultipartUploadRequest.RequestPayer.ToString()));
            }

            if (initiateMultipartUploadRequest.IsSetObjectLockLegalHoldStatus())
            {
                request.Headers.Add("x-amz-object-lock-legal-hold", S3Transforms.ToStringValue(initiateMultipartUploadRequest.ObjectLockLegalHoldStatus));
            }
            if (initiateMultipartUploadRequest.IsSetObjectLockMode())
            {
                request.Headers.Add("x-amz-object-lock-mode", S3Transforms.ToStringValue(initiateMultipartUploadRequest.ObjectLockMode));
            }
            if (initiateMultipartUploadRequest.IsSetObjectLockRetainUntilDate())
            {
                request.Headers.Add("x-amz-object-lock-retain-until-date", S3Transforms.ToStringValue(initiateMultipartUploadRequest.ObjectLockRetainUntilDate, AWSSDKUtils.ISO8601DateFormat));
            }

            if (initiateMultipartUploadRequest.IsSetTagSet())
            {
                request.Headers.Add(S3Constants.AmzHeaderTagging, AmazonS3Util.TagSetToQueryString(initiateMultipartUploadRequest.TagSet));
            }

            AmazonS3Util.SetMetadataHeaders(request, initiateMultipartUploadRequest.Metadata);

            if (string.IsNullOrEmpty(initiateMultipartUploadRequest.BucketName))
            {
                throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "InitiateMultipartUploadRequest.BucketName");
            }
            if (string.IsNullOrEmpty(initiateMultipartUploadRequest.Key))
            {
                throw new System.ArgumentException("Key is a required property and must be set before making this call.", "InitiateMultipartUploadRequest.Key");
            }

            request.ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}",
                                                 S3Transforms.ToStringValue(initiateMultipartUploadRequest.BucketName),
                                                 S3Transforms.ToStringValue(initiateMultipartUploadRequest.Key));

            request.AddSubResource("uploads");

            request.UseQueryString = true;

            return(request);
        }
        public IRequest Marshall(InitiateMultipartUploadRequest initiateMultipartUploadRequest)
        {
            IRequest request = new DefaultRequest(initiateMultipartUploadRequest, "AmazonS3");

            request.HttpMethod = "POST";

            if (initiateMultipartUploadRequest.IsSetCannedACL())
            {
                request.Headers.Add(HeaderKeys.XAmzAclHeader, S3Transforms.ToStringValue(initiateMultipartUploadRequest.CannedACL));
            }

            var headers = initiateMultipartUploadRequest.Headers;

            foreach (var key in headers.Keys)
            {
                request.Headers.Add(key, headers[key]);
            }

            HeaderACLRequestMarshaller.Marshall(request, initiateMultipartUploadRequest);

            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionHeader, S3Transforms.ToStringValue(initiateMultipartUploadRequest.ServerSideEncryptionMethod));
            }
            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, initiateMultipartUploadRequest.ServerSideEncryptionCustomerMethod);
            }
            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, initiateMultipartUploadRequest.ServerSideEncryptionCustomerProvidedKey);
                if (initiateMultipartUploadRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, initiateMultipartUploadRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(initiateMultipartUploadRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }

            if (initiateMultipartUploadRequest.IsSetServerSideEncryptionKeyManagementServiceKeyId())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionAwsKmsKeyIdHeader, initiateMultipartUploadRequest.ServerSideEncryptionKeyManagementServiceKeyId);
            }

            if (initiateMultipartUploadRequest.IsSetStorageClass())
            {
                request.Headers.Add(HeaderKeys.XAmzStorageClassHeader, S3Transforms.ToStringValue(initiateMultipartUploadRequest.StorageClass));
            }

            if (initiateMultipartUploadRequest.IsSetWebsiteRedirectLocation())
            {
                request.Headers.Add(HeaderKeys.XAmzWebsiteRedirectLocationHeader, S3Transforms.ToStringValue(initiateMultipartUploadRequest.WebsiteRedirectLocation));
            }

            AmazonS3Util.SetMetadataHeaders(request, initiateMultipartUploadRequest.Metadata);

            request.ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}",
                                                 S3Transforms.ToStringValue(initiateMultipartUploadRequest.BucketName),
                                                 S3Transforms.ToStringValue(initiateMultipartUploadRequest.Key));

            request.AddSubResource("uploads");

            request.UseQueryString = true;

            return(request);
        }
Ejemplo n.º 5
0
        public IRequest Marshall(PutObjectRequest putObjectRequest)
        {
            IRequest request = new DefaultRequest(putObjectRequest, "AmazonS3");

            request.HttpMethod = "PUT";

            if (putObjectRequest.IsSetCannedACL())
            {
                request.Headers.Add(HeaderKeys.XAmzAclHeader, S3Transforms.ToStringValue(putObjectRequest.CannedACL));
            }

            var headers = putObjectRequest.Headers;

            foreach (var key in headers.Keys)
            {
                request.Headers[key] = headers[key];
            }

            if (putObjectRequest.IsSetMD5Digest())
            {
                request.Headers[HeaderKeys.ContentMD5Header] = putObjectRequest.MD5Digest;
            }

            HeaderACLRequestMarshaller.Marshall(request, putObjectRequest);

            if (putObjectRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionHeader, S3Transforms.ToStringValue(putObjectRequest.ServerSideEncryptionMethod));
            }

            if (putObjectRequest.IsSetStorageClass())
            {
                request.Headers.Add(HeaderKeys.XAmzStorageClassHeader, S3Transforms.ToStringValue(putObjectRequest.StorageClass));
            }

            if (putObjectRequest.IsSetWebsiteRedirectLocation())
            {
                request.Headers.Add(HeaderKeys.XAmzWebsiteRedirectLocationHeader, S3Transforms.ToStringValue(putObjectRequest.WebsiteRedirectLocation));
            }

            if (putObjectRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, putObjectRequest.ServerSideEncryptionCustomerMethod);
            }
            if (putObjectRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, putObjectRequest.ServerSideEncryptionCustomerProvidedKey);
                if (putObjectRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, putObjectRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(putObjectRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }

            if (putObjectRequest.IsSetServerSideEncryptionKeyManagementServiceKeyId())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionAwsKmsKeyIdHeader, putObjectRequest.ServerSideEncryptionKeyManagementServiceKeyId);
            }

            if (putObjectRequest.IsSetServerSideEncryptionKeyManagementServiceEncryptionContext())
            {
                request.Headers.Add("x-amz-server-side-encryption-context", putObjectRequest.ServerSideEncryptionKeyManagementServiceEncryptionContext);
            }

            if (putObjectRequest.IsSetObjectLockLegalHoldStatus())
            {
                request.Headers.Add("x-amz-object-lock-legal-hold", S3Transforms.ToStringValue(putObjectRequest.ObjectLockLegalHoldStatus));
            }

            if (putObjectRequest.IsSetObjectLockMode())
            {
                request.Headers.Add("x-amz-object-lock-mode", S3Transforms.ToStringValue(putObjectRequest.ObjectLockMode));
            }

            if (putObjectRequest.IsSetObjectLockRetainUntilDate())
            {
                request.Headers.Add("x-amz-object-lock-retain-until-date", S3Transforms.ToStringValue(putObjectRequest.ObjectLockRetainUntilDate, AWSSDKUtils.ISO8601DateFormat));
            }

            if (putObjectRequest.IsSetRequestPayer())
            {
                request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(putObjectRequest.RequestPayer.ToString()));
            }

            if (putObjectRequest.IsSetTagSet())
            {
                request.Headers.Add(S3Constants.AmzHeaderTagging, AmazonS3Util.TagSetToQueryString(putObjectRequest.TagSet));
            }

            if (putObjectRequest.IsSetExpectedBucketOwner())
            {
                request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(putObjectRequest.ExpectedBucketOwner));
            }

            if (putObjectRequest.IsSetBucketKeyEnabled())
            {
                request.Headers.Add(S3Constants.AmzHeaderBucketKeyEnabled, S3Transforms.ToStringValue(putObjectRequest.BucketKeyEnabled));
            }

            AmazonS3Util.SetMetadataHeaders(request, putObjectRequest.Metadata);

            if (string.IsNullOrEmpty(putObjectRequest.BucketName))
            {
                throw new System.ArgumentException("BucketName is a required property and must be set before making this call.", "PutObjectRequest.BucketName");
            }
            if (string.IsNullOrEmpty(putObjectRequest.Key))
            {
                throw new System.ArgumentException("Key is a required property and must be set before making this call.", "PutObjectRequest.Key");
            }

            request.ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}",
                                                 S3Transforms.ToStringValue(putObjectRequest.BucketName),
                                                 S3Transforms.ToStringValue(putObjectRequest.Key));


            if (putObjectRequest.InputStream != null)
            {
                // Wrap the stream in a stream that has a length
                var streamWithLength = GetStreamWithLength(putObjectRequest.InputStream, putObjectRequest.Headers.ContentLength);
                if (streamWithLength.Length > 0 && !(putObjectRequest.DisablePayloadSigning ?? false))
                {
                    request.UseChunkEncoding = putObjectRequest.UseChunkEncoding;
                }
                var length = streamWithLength.Length - streamWithLength.Position;
                if (!request.Headers.ContainsKey(HeaderKeys.ContentLengthHeader))
                {
                    request.Headers.Add(HeaderKeys.ContentLengthHeader, length.ToString(CultureInfo.InvariantCulture));
                }

                request.DisablePayloadSigning = putObjectRequest.DisablePayloadSigning;

                if (!(putObjectRequest.DisableMD5Stream ?? AWSConfigsS3.DisableMD5Stream))
                {
                    // Wrap input stream in MD5Stream
                    var hashStream = new MD5Stream(streamWithLength, null, length);
                    putObjectRequest.InputStream = hashStream;
                }
                else
                {
                    putObjectRequest.InputStream = streamWithLength;
                }
            }

            request.ContentStream = putObjectRequest.InputStream;
            if (!request.Headers.ContainsKey(HeaderKeys.ContentTypeHeader))
            {
                request.Headers.Add(HeaderKeys.ContentTypeHeader, "text/plain");
            }

            return(request);
        }
        public IRequest Marshall(CopyObjectRequest copyObjectRequest)
        {
            var sourceKey      = AmazonS3Util.RemoveLeadingSlash(copyObjectRequest.SourceKey);
            var destinationKey = AmazonS3Util.RemoveLeadingSlash(copyObjectRequest.DestinationKey);

            IRequest request = new DefaultRequest(copyObjectRequest, "AmazonS3");

            request.HttpMethod = "PUT";

            if (copyObjectRequest.IsSetCannedACL())
            {
                request.Headers.Add(HeaderKeys.XAmzAclHeader, S3Transforms.ToStringValue(copyObjectRequest.CannedACL));
            }

            var headers = copyObjectRequest.Headers;

            foreach (var key in headers.Keys)
            {
                request.Headers[key] = headers[key];
            }

            HeaderACLRequestMarshaller.Marshall(request, copyObjectRequest);

            if (copyObjectRequest.IsSetSourceBucket())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceHeader, ConstructCopySourceHeaderValue(copyObjectRequest.SourceBucket, sourceKey, copyObjectRequest.SourceVersionId));
            }

            if (copyObjectRequest.IsSetETagToMatch())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfMatchHeader, S3Transforms.ToStringValue(copyObjectRequest.ETagToMatch));
            }

            if (copyObjectRequest.IsSetModifiedSinceDateUtc())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfModifiedSinceHeader, S3Transforms.ToStringValue(copyObjectRequest.ModifiedSinceDateUtc));
            }

            if (copyObjectRequest.IsSetETagToNotMatch())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfNoneMatchHeader, S3Transforms.ToStringValue(copyObjectRequest.ETagToNotMatch));
            }

            if (copyObjectRequest.IsSetUnmodifiedSinceDateUtc())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfUnmodifiedSinceHeader, S3Transforms.ToStringValue(copyObjectRequest.UnmodifiedSinceDateUtc));
            }

            if (copyObjectRequest.IsSetTagSet())
            {
                request.Headers.Add(S3Constants.AmzHeaderTagging, AmazonS3Util.TagSetToQueryString(copyObjectRequest.TagSet));
                request.Headers.Add(S3Constants.AmzHeaderTaggingDirective, TaggingDirective.REPLACE.Value);
            }
            else
            {
                request.Headers.Add(S3Constants.AmzHeaderTaggingDirective, TaggingDirective.COPY.Value);
            }

            request.Headers.Add(HeaderKeys.XAmzMetadataDirectiveHeader, S3Transforms.ToStringValue(copyObjectRequest.MetadataDirective.ToString()));

            if (copyObjectRequest.IsSetObjectLockLegalHoldStatus())
            {
                request.Headers.Add("x-amz-object-lock-legal-hold", S3Transforms.ToStringValue(copyObjectRequest.ObjectLockLegalHoldStatus));
            }
            if (copyObjectRequest.IsSetObjectLockMode())
            {
                request.Headers.Add("x-amz-object-lock-mode", S3Transforms.ToStringValue(copyObjectRequest.ObjectLockMode));
            }
            if (copyObjectRequest.IsSetObjectLockRetainUntilDate())
            {
                request.Headers.Add("x-amz-object-lock-retain-until-date", S3Transforms.ToStringValue(copyObjectRequest.ObjectLockRetainUntilDate, AWSSDKUtils.ISO8601DateFormat));
            }

            if (copyObjectRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionHeader, S3Transforms.ToStringValue(copyObjectRequest.ServerSideEncryptionMethod));
            }
            if (copyObjectRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, copyObjectRequest.ServerSideEncryptionCustomerMethod);
            }
            if (copyObjectRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, copyObjectRequest.ServerSideEncryptionCustomerProvidedKey);
                if (copyObjectRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, copyObjectRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(copyObjectRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (copyObjectRequest.IsSetCopySourceServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerAlgorithmHeader, copyObjectRequest.CopySourceServerSideEncryptionCustomerMethod);
            }
            if (copyObjectRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerKeyHeader, copyObjectRequest.CopySourceServerSideEncryptionCustomerProvidedKey);
                if (copyObjectRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerKeyMD5Header, copyObjectRequest.CopySourceServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(copyObjectRequest.CopySourceServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (copyObjectRequest.IsSetServerSideEncryptionKeyManagementServiceKeyId())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionAwsKmsKeyIdHeader, copyObjectRequest.ServerSideEncryptionKeyManagementServiceKeyId);
            }

            if (copyObjectRequest.IsSetServerSideEncryptionKeyManagementServiceEncryptionContext())
            {
                request.Headers.Add("x-amz-server-side-encryption-context", copyObjectRequest.ServerSideEncryptionKeyManagementServiceEncryptionContext);
            }

            if (copyObjectRequest.IsSetStorageClass())
            {
                request.Headers.Add(HeaderKeys.XAmzStorageClassHeader, S3Transforms.ToStringValue(copyObjectRequest.StorageClass));
            }

            if (copyObjectRequest.IsSetWebsiteRedirectLocation())
            {
                request.Headers.Add(HeaderKeys.XAmzWebsiteRedirectLocationHeader, S3Transforms.ToStringValue(copyObjectRequest.WebsiteRedirectLocation));
            }

            if (copyObjectRequest.IsSetRequestPayer())
            {
                request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(copyObjectRequest.RequestPayer.ToString()));
            }

            if (copyObjectRequest.IsSetExpectedBucketOwner())
            {
                request.Headers.Add(S3Constants.AmzHeaderExpectedBucketOwner, S3Transforms.ToStringValue(copyObjectRequest.ExpectedBucketOwner));
            }

            if (copyObjectRequest.IsSetExpectedSourceBucketOwner())
            {
                request.Headers.Add(S3Constants.AmzHeaderExpectedSourceBucketOwner, S3Transforms.ToStringValue(copyObjectRequest.ExpectedSourceBucketOwner));
            }

            if (copyObjectRequest.IsSetBucketKeyEnabled())
            {
                request.Headers.Add(S3Constants.AmzHeaderBucketKeyEnabled, S3Transforms.ToStringValue(copyObjectRequest.BucketKeyEnabled));
            }


            AmazonS3Util.SetMetadataHeaders(request, copyObjectRequest.Metadata);

            if (string.IsNullOrEmpty(copyObjectRequest.DestinationBucket))
            {
                throw new System.ArgumentException("DestinationBucket is a required property and must be set before making this call.", "CopyObjectRequest.DestinationBucket");
            }
            if (string.IsNullOrEmpty(destinationKey))
            {
                throw new System.ArgumentException("DestinationKey is a required property and must be set before making this call.", "CopyObjectRequest.DestinationKey");
            }


            request.MarshallerVersion = 2;
            request.ResourcePath      = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}",
                                                      S3Transforms.ToStringValue(copyObjectRequest.DestinationBucket),
                                                      S3Transforms.ToStringValue(destinationKey));


            request.UseQueryString = true;

            return(request);
        }
        public IRequest Marshall(CopyObjectRequest copyObjectRequest)
        {
            IRequest request = new DefaultRequest(copyObjectRequest, "AmazonS3");

            request.HttpMethod = "PUT";

            if (copyObjectRequest.IsSetCannedACL())
            {
                request.Headers.Add(HeaderKeys.XAmzAclHeader, S3Transforms.ToStringValue(copyObjectRequest.CannedACL));
            }

            var headers = copyObjectRequest.Headers;

            foreach (var key in headers.Keys)
            {
                request.Headers[key] = headers[key];
            }

            HeaderACLRequestMarshaller.Marshall(request, copyObjectRequest);

            if (copyObjectRequest.IsSetSourceBucket())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceHeader, ConstructCopySourceHeaderValue(copyObjectRequest.SourceBucket, copyObjectRequest.SourceKey, copyObjectRequest.SourceVersionId));
            }

            if (copyObjectRequest.IsSetETagToMatch())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfMatchHeader, S3Transforms.ToStringValue(copyObjectRequest.ETagToMatch));
            }

            if (copyObjectRequest.IsSetModifiedSinceDate())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfModifiedSinceHeader, S3Transforms.ToStringValue(copyObjectRequest.ModifiedSinceDate));
            }

            if (copyObjectRequest.IsSetETagToNotMatch())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfNoneMatchHeader, S3Transforms.ToStringValue(copyObjectRequest.ETagToNotMatch));
            }

            if (copyObjectRequest.IsSetUnmodifiedSinceDate())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfUnmodifiedSinceHeader, S3Transforms.ToStringValue(copyObjectRequest.UnmodifiedSinceDate));
            }

            request.Headers.Add(HeaderKeys.XAmzMetadataDirectiveHeader, S3Transforms.ToStringValue(copyObjectRequest.MetadataDirective.ToString()));

            if (copyObjectRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionHeader, S3Transforms.ToStringValue(copyObjectRequest.ServerSideEncryptionMethod));
            }
            if (copyObjectRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, copyObjectRequest.ServerSideEncryptionCustomerMethod);
            }
            if (copyObjectRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, copyObjectRequest.ServerSideEncryptionCustomerProvidedKey);
                if (copyObjectRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, copyObjectRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(copyObjectRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (copyObjectRequest.IsSetCopySourceServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerAlgorithmHeader, copyObjectRequest.CopySourceServerSideEncryptionCustomerMethod);
            }
            if (copyObjectRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerKeyHeader, copyObjectRequest.CopySourceServerSideEncryptionCustomerProvidedKey);
                if (copyObjectRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerKeyMD5Header, copyObjectRequest.CopySourceServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(copyObjectRequest.CopySourceServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (copyObjectRequest.IsSetServerSideEncryptionKeyManagementServiceKeyId())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionAwsKmsKeyIdHeader, copyObjectRequest.ServerSideEncryptionKeyManagementServiceKeyId);
            }

            if (copyObjectRequest.IsSetStorageClass())
            {
                request.Headers.Add(HeaderKeys.XAmzStorageClassHeader, S3Transforms.ToStringValue(copyObjectRequest.StorageClass));
            }

            if (copyObjectRequest.IsSetWebsiteRedirectLocation())
            {
                request.Headers.Add(HeaderKeys.XAmzWebsiteRedirectLocationHeader, S3Transforms.ToStringValue(copyObjectRequest.WebsiteRedirectLocation));
            }

            AmazonS3Util.SetMetadataHeaders(request, copyObjectRequest.Metadata);

            var destinationKey = copyObjectRequest.DestinationKey.StartsWith("/", StringComparison.Ordinal)
                                    ? copyObjectRequest.DestinationKey.Substring(1)
                                    : copyObjectRequest.DestinationKey;

            request.ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}",
                                                 S3Transforms.ToStringValue(copyObjectRequest.DestinationBucket),
                                                 S3Transforms.ToStringValue(destinationKey));


            request.UseQueryString = true;

            return(request);
        }
Ejemplo n.º 8
0
        public IRequest Marshall(PutObjectRequest putObjectRequest)
        {
            IRequest request = new DefaultRequest(putObjectRequest, "AmazonS3");

            request.HttpMethod = "PUT";

            if (putObjectRequest.IsSetCannedACL())
            {
                request.Headers.Add(HeaderKeys.XAmzAclHeader, S3Transforms.ToStringValue(putObjectRequest.CannedACL));
            }

            var headers = putObjectRequest.Headers;

            foreach (var key in headers.Keys)
            {
                request.Headers[key] = headers[key];
            }

            if (putObjectRequest.IsSetMD5Digest())
            {
                request.Headers[HeaderKeys.ContentMD5Header] = putObjectRequest.MD5Digest;
            }

            HeaderACLRequestMarshaller.Marshall(request, putObjectRequest);

            if (putObjectRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzServerSideEncryptionHeader, S3Transforms.ToStringValue(putObjectRequest.ServerSideEncryptionMethod));
            }

            if (putObjectRequest.IsSetStorageClass())
            {
                request.Headers.Add(HeaderKeys.XAmzStorageClassHeader, S3Transforms.ToStringValue(putObjectRequest.StorageClass));
            }

            if (putObjectRequest.IsSetWebsiteRedirectLocation())
            {
                request.Headers.Add(HeaderKeys.XAmzWebsiteRedirectLocationHeader, S3Transforms.ToStringValue(putObjectRequest.WebsiteRedirectLocation));
            }

            if (putObjectRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, putObjectRequest.ServerSideEncryptionCustomerMethod);
            }
            if (putObjectRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, putObjectRequest.ServerSideEncryptionCustomerProvidedKey);
                if (putObjectRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, putObjectRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(putObjectRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }

            AmazonS3Util.SetMetadataHeaders(request, putObjectRequest.Metadata);

            request.ResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}",
                                                 S3Transforms.ToStringValue(putObjectRequest.BucketName),
                                                 S3Transforms.ToStringValue(putObjectRequest.Key));


            if (putObjectRequest.InputStream != null)
            {
                // Wrap the stream in a stream that has a length
                var streamWithLength = GetStreamWithLength(putObjectRequest.InputStream, putObjectRequest.Headers.ContentLength);
                if (streamWithLength.Length > 0)
                {
                    request.UseChunkEncoding = true;
                }
                var length = streamWithLength.Length - streamWithLength.Position;
                if (!request.Headers.ContainsKey(HeaderKeys.ContentLengthHeader))
                {
                    request.Headers.Add(HeaderKeys.ContentLengthHeader, length.ToString(CultureInfo.InvariantCulture));
                }

                // Wrap input stream in MD5Stream
                var hashStream = new MD5Stream(streamWithLength, null, length);
                putObjectRequest.InputStream = hashStream;
            }

            request.ContentStream = putObjectRequest.InputStream;
            if (!request.Headers.ContainsKey(HeaderKeys.ContentTypeHeader))
            {
                request.Headers.Add(HeaderKeys.ContentTypeHeader, "text/plain");
            }

            return(request);
        }
Ejemplo n.º 9
0
        public IRequest Marshall(PutObjectRequest putObjectRequest)
        {
            IRequest request = new DefaultRequest(putObjectRequest, "AmazonS3");

            request.HttpMethod = "PUT";

            if (putObjectRequest.IsSetCannedACL())
            {
                request.Headers.Add("x-amz-acl", S3Transforms.ToStringValue(putObjectRequest.CannedACL));
            }

            var headers = putObjectRequest.Headers;

            foreach (var key in headers.Keys)
            {
                request.Headers[key] = headers[key];
            }

            if (putObjectRequest.IsSetMD5Digest())
            {
                request.Headers["Content-MD5"] = putObjectRequest.MD5Digest;
            }

            HeaderACLRequestMarshaller.Marshall(request, putObjectRequest);

            if (putObjectRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers.Add("x-amz-server-side-encryption", S3Transforms.ToStringValue(putObjectRequest.ServerSideEncryptionMethod));
            }

            if (putObjectRequest.IsSetStorageClass())
            {
                request.Headers.Add("x-amz-storage-class", S3Transforms.ToStringValue(putObjectRequest.StorageClass));
            }

            if (putObjectRequest.IsSetWebsiteRedirectLocation())
            {
                request.Headers.Add("x-amz-website-redirect-location", S3Transforms.ToStringValue(putObjectRequest.WebsiteRedirectLocation));
            }

            AmazonS3Util.SetMetadataHeaders(request, putObjectRequest.Metadata);

            var uriResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}",
                                                S3Transforms.ToStringValue(putObjectRequest.BucketName),
                                                S3Transforms.ToStringValue(putObjectRequest.Key));


            request.CanonicalResource = S3Transforms.GetCanonicalResource(uriResourcePath, request.Parameters);
            request.ResourcePath      = S3Transforms.FormatResourcePath(uriResourcePath, request.Parameters);

            if (putObjectRequest.InputStream != null)
            {
                // Wrap the stream in a stream that has a length
                var streamWithLength = GetStreamWithLength(putObjectRequest.InputStream, putObjectRequest.Headers.ContentLength);
                if (streamWithLength.Length > 0)
                {
                    request.UseChunkEncoding = true;
                }
                var length = streamWithLength.Length - streamWithLength.Position;
                if (!request.Headers.ContainsKey("Content-Length"))
                {
                    request.Headers.Add("Content-Length", length.ToString(CultureInfo.InvariantCulture));
                }

                // Wrap input stream in MD5Stream
                var hashStream = new MD5Stream(streamWithLength, null, length);
                putObjectRequest.InputStream = hashStream;
            }

            request.ContentStream = putObjectRequest.InputStream;
            if (!request.Headers.ContainsKey("Content-Type"))
            {
                request.Headers.Add("Content-Type", "text/plain");
            }

            if (!request.UseQueryString)
            {
                var queryString = AWSSDKUtils.GetParametersAsString(request.Parameters);
                if (!string.IsNullOrEmpty(queryString))
                {
                    request.ResourcePath = string.Concat(request.ResourcePath, request.ResourcePath.Contains("?") ? "&" : "?", queryString);
                }
            }

            return(request);
        }
Ejemplo n.º 10
0
        public IRequest Marshall(CopyObjectRequest copyObjectRequest)
        {
            //IL_0006: Unknown result type (might be due to invalid IL or missing references)
            //IL_000c: Expected O, but got Unknown
            IRequest val = new DefaultRequest(copyObjectRequest, "AmazonS3");

            val.set_HttpMethod("PUT");
            if (copyObjectRequest.IsSetCannedACL())
            {
                val.get_Headers().Add("x-amz-acl", S3Transforms.ToStringValue(ConstantClass.op_Implicit(copyObjectRequest.CannedACL)));
            }
            HeadersCollection headers = copyObjectRequest.Headers;

            foreach (string key in headers.Keys)
            {
                val.get_Headers()[key] = headers[key];
            }
            HeaderACLRequestMarshaller.Marshall(val, copyObjectRequest);
            if (copyObjectRequest.IsSetSourceBucket())
            {
                val.get_Headers().Add("x-amz-copy-source", ConstructCopySourceHeaderValue(copyObjectRequest.SourceBucket, copyObjectRequest.SourceKey, copyObjectRequest.SourceVersionId));
            }
            if (copyObjectRequest.IsSetETagToMatch())
            {
                val.get_Headers().Add("x-amz-copy-source-if-match", S3Transforms.ToStringValue(copyObjectRequest.ETagToMatch));
            }
            if (copyObjectRequest.IsSetModifiedSinceDate())
            {
                val.get_Headers().Add("x-amz-copy-source-if-modified-since", S3Transforms.ToStringValue(copyObjectRequest.ModifiedSinceDate));
            }
            if (copyObjectRequest.IsSetETagToNotMatch())
            {
                val.get_Headers().Add("x-amz-copy-source-if-none-match", S3Transforms.ToStringValue(copyObjectRequest.ETagToNotMatch));
            }
            if (copyObjectRequest.IsSetUnmodifiedSinceDate())
            {
                val.get_Headers().Add("x-amz-copy-source-if-unmodified-since", S3Transforms.ToStringValue(copyObjectRequest.UnmodifiedSinceDate));
            }
            if (copyObjectRequest.IsSetTagSet())
            {
                val.get_Headers().Add(S3Constants.AmzHeaderTagging, AmazonS3Util.TagSetToQueryString(copyObjectRequest.TagSet));
                val.get_Headers().Add(S3Constants.AmzHeaderTaggingDirective, TaggingDirective.REPLACE.get_Value());
            }
            else
            {
                val.get_Headers().Add(S3Constants.AmzHeaderTaggingDirective, TaggingDirective.COPY.get_Value());
            }
            val.get_Headers().Add("x-amz-metadata-directive", S3Transforms.ToStringValue(copyObjectRequest.MetadataDirective.ToString()));
            if (copyObjectRequest.IsSetServerSideEncryptionMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption", S3Transforms.ToStringValue(ConstantClass.op_Implicit(copyObjectRequest.ServerSideEncryptionMethod)));
            }
            if (copyObjectRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-algorithm", ConstantClass.op_Implicit(copyObjectRequest.ServerSideEncryptionCustomerMethod));
            }
            if (copyObjectRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-key", copyObjectRequest.ServerSideEncryptionCustomerProvidedKey);
                if (copyObjectRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", copyObjectRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", AmazonS3Util.ComputeEncodedMD5FromEncodedString(copyObjectRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (copyObjectRequest.IsSetCopySourceServerSideEncryptionCustomerMethod())
            {
                val.get_Headers().Add("x-amz-copy-source-server-side-encryption-customer-algorithm", ConstantClass.op_Implicit(copyObjectRequest.CopySourceServerSideEncryptionCustomerMethod));
            }
            if (copyObjectRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKey())
            {
                val.get_Headers().Add("x-amz-copy-source-server-side-encryption-customer-key", copyObjectRequest.CopySourceServerSideEncryptionCustomerProvidedKey);
                if (copyObjectRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    val.get_Headers().Add("x-amz-copy-source-server-side-encryption-customer-key-MD5", copyObjectRequest.CopySourceServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    val.get_Headers().Add("x-amz-copy-source-server-side-encryption-customer-key-MD5", AmazonS3Util.ComputeEncodedMD5FromEncodedString(copyObjectRequest.CopySourceServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (copyObjectRequest.IsSetServerSideEncryptionKeyManagementServiceKeyId())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-aws-kms-key-id", copyObjectRequest.ServerSideEncryptionKeyManagementServiceKeyId);
            }
            if (copyObjectRequest.IsSetStorageClass())
            {
                val.get_Headers().Add("x-amz-storage-class", S3Transforms.ToStringValue(ConstantClass.op_Implicit(copyObjectRequest.StorageClass)));
            }
            if (copyObjectRequest.IsSetWebsiteRedirectLocation())
            {
                val.get_Headers().Add("x-amz-website-redirect-location", S3Transforms.ToStringValue(copyObjectRequest.WebsiteRedirectLocation));
            }
            if (copyObjectRequest.IsSetRequestPayer())
            {
                val.get_Headers().Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(((object)copyObjectRequest.RequestPayer).ToString()));
            }
            AmazonS3Util.SetMetadataHeaders(val, copyObjectRequest.Metadata);
            string value = copyObjectRequest.DestinationKey.StartsWith("/", StringComparison.Ordinal) ? copyObjectRequest.DestinationKey.Substring(1) : copyObjectRequest.DestinationKey;

            val.set_ResourcePath(string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(copyObjectRequest.DestinationBucket), S3Transforms.ToStringValue(value)));
            val.set_UseQueryString(true);
            return(val);
        }
        public IRequest Marshall(PutObjectRequest putObjectRequest)
        {
            //IL_0006: Unknown result type (might be due to invalid IL or missing references)
            //IL_000c: Expected O, but got Unknown
            //IL_02b8: Unknown result type (might be due to invalid IL or missing references)
            //IL_02bf: Expected O, but got Unknown
            IRequest val = new DefaultRequest(putObjectRequest, "AmazonS3");

            val.set_HttpMethod("PUT");
            if (putObjectRequest.IsSetCannedACL())
            {
                val.get_Headers().Add("x-amz-acl", S3Transforms.ToStringValue(ConstantClass.op_Implicit(putObjectRequest.CannedACL)));
            }
            HeadersCollection headers = putObjectRequest.Headers;

            foreach (string key in headers.Keys)
            {
                val.get_Headers()[key] = headers[key];
            }
            if (putObjectRequest.IsSetMD5Digest())
            {
                val.get_Headers()["Content-MD5"] = putObjectRequest.MD5Digest;
            }
            HeaderACLRequestMarshaller.Marshall(val, putObjectRequest);
            if (putObjectRequest.IsSetServerSideEncryptionMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption", S3Transforms.ToStringValue(ConstantClass.op_Implicit(putObjectRequest.ServerSideEncryptionMethod)));
            }
            if (putObjectRequest.IsSetStorageClass())
            {
                val.get_Headers().Add("x-amz-storage-class", S3Transforms.ToStringValue(ConstantClass.op_Implicit(putObjectRequest.StorageClass)));
            }
            if (putObjectRequest.IsSetWebsiteRedirectLocation())
            {
                val.get_Headers().Add("x-amz-website-redirect-location", S3Transforms.ToStringValue(putObjectRequest.WebsiteRedirectLocation));
            }
            if (putObjectRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-algorithm", ConstantClass.op_Implicit(putObjectRequest.ServerSideEncryptionCustomerMethod));
            }
            if (putObjectRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-key", putObjectRequest.ServerSideEncryptionCustomerProvidedKey);
                if (putObjectRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", putObjectRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", AmazonS3Util.ComputeEncodedMD5FromEncodedString(putObjectRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (putObjectRequest.IsSetServerSideEncryptionKeyManagementServiceKeyId())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-aws-kms-key-id", putObjectRequest.ServerSideEncryptionKeyManagementServiceKeyId);
            }
            if (putObjectRequest.IsSetRequestPayer())
            {
                val.get_Headers().Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(((object)putObjectRequest.RequestPayer).ToString()));
            }
            if (putObjectRequest.IsSetTagSet())
            {
                val.get_Headers().Add(S3Constants.AmzHeaderTagging, AmazonS3Util.TagSetToQueryString(putObjectRequest.TagSet));
            }
            AmazonS3Util.SetMetadataHeaders(val, putObjectRequest.Metadata);
            val.set_ResourcePath(string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(putObjectRequest.BucketName), S3Transforms.ToStringValue(putObjectRequest.Key)));
            if (putObjectRequest.InputStream != null)
            {
                Stream streamWithLength = GetStreamWithLength(putObjectRequest.InputStream, putObjectRequest.Headers.ContentLength);
                if (streamWithLength.Length > 0)
                {
                    val.set_UseChunkEncoding(true);
                }
                long num = streamWithLength.Length - streamWithLength.Position;
                if (!val.get_Headers().ContainsKey("Content-Length"))
                {
                    val.get_Headers().Add("Content-Length", num.ToString(CultureInfo.InvariantCulture));
                }
                MD5Stream val2 = putObjectRequest.InputStream = (Stream) new MD5Stream(streamWithLength, (byte[])null, num);
            }
            val.set_ContentStream(putObjectRequest.InputStream);
            if (!val.get_Headers().ContainsKey("Content-Type"))
            {
                val.get_Headers().Add("Content-Type", "text/plain");
            }
            return(val);
        }
Ejemplo n.º 12
0
        public IRequest Marshall(CopyObjectRequest copyObjectRequest)
        {
            IRequest request = new DefaultRequest(copyObjectRequest, "AmazonS3");

            request.HttpMethod = "PUT";

            if (copyObjectRequest.IsSetCannedACL())
            {
                request.Headers.Add("x-amz-acl", S3Transforms.ToStringValue(copyObjectRequest.CannedACL));
            }

            var headers = copyObjectRequest.Headers;

            foreach (var key in headers.Keys)
            {
                request.Headers[key] = headers[key];
            }

            HeaderACLRequestMarshaller.Marshall(request, copyObjectRequest);

            if (copyObjectRequest.IsSetSourceBucket())
            {
                request.Headers.Add("x-amz-copy-source", ConstructCopySourceHeaderValue(copyObjectRequest.SourceBucket, copyObjectRequest.SourceKey, copyObjectRequest.SourceVersionId));
            }

            if (copyObjectRequest.IsSetETagToMatch())
            {
                request.Headers.Add("x-amz-copy-source-if-match", S3Transforms.ToStringValue(copyObjectRequest.ETagToMatch));
            }

            if (copyObjectRequest.IsSetModifiedSinceDate())
            {
                request.Headers.Add("x-amz-copy-source-if-modified-since", S3Transforms.ToStringValue(copyObjectRequest.ModifiedSinceDate));
            }

            if (copyObjectRequest.IsSetETagToNotMatch())
            {
                request.Headers.Add("x-amz-copy-source-if-none-match", S3Transforms.ToStringValue(copyObjectRequest.ETagToNotMatch));
            }

            if (copyObjectRequest.IsSetUnmodifiedSinceDate())
            {
                request.Headers.Add("x-amz-copy-source-if-unmodified-since", S3Transforms.ToStringValue(copyObjectRequest.UnmodifiedSinceDate));
            }

            request.Headers.Add("x-amz-metadata-directive", S3Transforms.ToStringValue(copyObjectRequest.MetadataDirective.ToString()));

            if (copyObjectRequest.IsSetServerSideEncryptionMethod())
            {
                request.Headers.Add("x-amz-server-side-encryption", S3Transforms.ToStringValue(copyObjectRequest.ServerSideEncryptionMethod));
            }

            if (copyObjectRequest.IsSetStorageClass())
            {
                request.Headers.Add("x-amz-storage-class", S3Transforms.ToStringValue(copyObjectRequest.StorageClass));
            }

            if (copyObjectRequest.IsSetWebsiteRedirectLocation())
            {
                request.Headers.Add("x-amz-website-redirect-location", S3Transforms.ToStringValue(copyObjectRequest.WebsiteRedirectLocation));
            }

            AmazonS3Util.SetMetadataHeaders(request, copyObjectRequest.Metadata);

            var uriResourcePath = string.Format(CultureInfo.InvariantCulture, "/{0}/{1}",
                                                S3Transforms.ToStringValue(copyObjectRequest.DestinationBucket),
                                                S3Transforms.ToStringValue(copyObjectRequest.DestinationKey));


            request.CanonicalResource = S3Transforms.GetCanonicalResource(uriResourcePath, request.Parameters);
            request.ResourcePath      = S3Transforms.FormatResourcePath(uriResourcePath, request.Parameters);
            request.UseQueryString    = true;

            return(request);
        }