Esempio n. 1
0
        public IRequest Marshall(GetObjectMetadataRequest headObjectRequest)
        {
            IRequest request = new DefaultRequest(headObjectRequest, "AmazonS3");

            request.HttpMethod = "HEAD";

            if (headObjectRequest.IsSetEtagToMatch())
            {
                request.Headers.Add(HeaderKeys.IfMatchHeader, S3Transforms.ToStringValue(headObjectRequest.EtagToMatch));
            }

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

            if (headObjectRequest.IsSetEtagToNotMatch())
            {
                request.Headers.Add(HeaderKeys.IfNoneMatchHeader, S3Transforms.ToStringValue(headObjectRequest.EtagToNotMatch));
            }

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

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

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

            if (headObjectRequest.IsSetVersionId())
            {
                request.AddSubResource("versionId", S3Transforms.ToStringValue(headObjectRequest.VersionId));
            }

            request.UseQueryString = true;

            return(request);
        }
Esempio n. 2
0
        public IRequest Marshall(GetObjectMetadataRequest headObjectRequest)
        {
            if (string.IsNullOrEmpty(headObjectRequest.Key))
            {
                throw new System.ArgumentException("Key is a required property and must be set before making this call.", "GetObjectMetadataRequest.Key");
            }

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

            request.HttpMethod = "HEAD";

            if (headObjectRequest.IsSetEtagToMatch())
            {
                request.Headers.Add(HeaderKeys.IfMatchHeader, S3Transforms.ToStringValue(headObjectRequest.EtagToMatch));
            }

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

            if (headObjectRequest.IsSetEtagToNotMatch())
            {
                request.Headers.Add(HeaderKeys.IfNoneMatchHeader, S3Transforms.ToStringValue(headObjectRequest.EtagToNotMatch));
            }

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

            if (headObjectRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, headObjectRequest.ServerSideEncryptionCustomerMethod);
            }
            if (headObjectRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, headObjectRequest.ServerSideEncryptionCustomerProvidedKey);
                if (headObjectRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, headObjectRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(headObjectRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (headObjectRequest.IsSetRequestPayer())
            {
                request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(headObjectRequest.RequestPayer.ToString()));
            }

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

            if (headObjectRequest.IsSetVersionId())
            {
                request.AddSubResource("versionId", S3Transforms.ToStringValue(headObjectRequest.VersionId));
            }
            if (headObjectRequest.IsSetPartNumber())
            {
                request.AddSubResource("partNumber", S3Transforms.ToStringValue(headObjectRequest.PartNumber.Value));
            }

            request.UseQueryString = true;

            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(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);
        }
        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);
        }
        public IRequest Marshall(CopyPartRequest copyPartRequest)
        {
            //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(copyPartRequest, "AmazonS3");

            val.set_HttpMethod("PUT");
            if (copyPartRequest.IsSetSourceBucket())
            {
                val.get_Headers().Add("x-amz-copy-source", ConstructCopySourceHeaderValue(copyPartRequest.SourceBucket, copyPartRequest.SourceKey, copyPartRequest.SourceVersionId));
            }
            if (copyPartRequest.IsSetETagToMatch())
            {
                val.get_Headers().Add("x-amz-copy-source-if-match", AWSSDKUtils.Join(copyPartRequest.ETagToMatch));
            }
            if (copyPartRequest.IsSetETagToNotMatch())
            {
                val.get_Headers().Add("x-amz-copy-source-if-none-match", AWSSDKUtils.Join(copyPartRequest.ETagsToNotMatch));
            }
            if (copyPartRequest.IsSetModifiedSinceDate())
            {
                val.get_Headers().Add("x-amz-copy-source-if-modified-since", copyPartRequest.ModifiedSinceDate.ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss \\G\\M\\T", CultureInfo.InvariantCulture));
            }
            if (copyPartRequest.IsSetUnmodifiedSinceDate())
            {
                val.get_Headers().Add("x-amz-copy-source-if-unmodified-since", copyPartRequest.UnmodifiedSinceDate.ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss \\G\\M\\T", CultureInfo.InvariantCulture));
            }
            if (copyPartRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-algorithm", ConstantClass.op_Implicit(copyPartRequest.ServerSideEncryptionCustomerMethod));
            }
            if (copyPartRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-key", copyPartRequest.ServerSideEncryptionCustomerProvidedKey);
                if (copyPartRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", copyPartRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", AmazonS3Util.ComputeEncodedMD5FromEncodedString(copyPartRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (copyPartRequest.IsSetCopySourceServerSideEncryptionCustomerMethod())
            {
                val.get_Headers().Add("x-amz-copy-source-server-side-encryption-customer-algorithm", ConstantClass.op_Implicit(copyPartRequest.CopySourceServerSideEncryptionCustomerMethod));
            }
            if (copyPartRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKey())
            {
                val.get_Headers().Add("x-amz-copy-source-server-side-encryption-customer-key", copyPartRequest.CopySourceServerSideEncryptionCustomerProvidedKey);
                if (copyPartRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    val.get_Headers().Add("x-amz-copy-source-server-side-encryption-customer-key-MD5", copyPartRequest.CopySourceServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    val.get_Headers().Add("x-amz-copy-source-server-side-encryption-customer-key-MD5", AmazonS3Util.ComputeEncodedMD5FromEncodedString(copyPartRequest.CopySourceServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (copyPartRequest.IsSetServerSideEncryptionKeyManagementServiceKeyId())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-aws-kms-key-id", copyPartRequest.ServerSideEncryptionKeyManagementServiceKeyId);
            }
            if (copyPartRequest.IsSetFirstByte() && copyPartRequest.IsSetLastByte())
            {
                val.get_Headers().Add("x-amz-copy-source-range", ConstructCopySourceRangeHeader(copyPartRequest.FirstByte, copyPartRequest.LastByte));
            }
            val.set_ResourcePath(string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(copyPartRequest.DestinationBucket), S3Transforms.ToStringValue(copyPartRequest.DestinationKey)));
            val.AddSubResource("partNumber", S3Transforms.ToStringValue(copyPartRequest.PartNumber));
            val.AddSubResource("uploadId", S3Transforms.ToStringValue(copyPartRequest.UploadId));
            val.set_UseQueryString(true);
            return(val);
        }
Esempio n. 7
0
        public IRequest Marshall(UploadPartRequest uploadPartRequest)
        {
            IRequest request = new DefaultRequest(uploadPartRequest, "AmazonS3");

            request.HttpMethod = "PUT";

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

            if (uploadPartRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, uploadPartRequest.ServerSideEncryptionCustomerMethod);
            }
            if (uploadPartRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, uploadPartRequest.ServerSideEncryptionCustomerProvidedKey);
                if (uploadPartRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, uploadPartRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(uploadPartRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (uploadPartRequest.IsSetRequestPayer())
            {
                request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(uploadPartRequest.RequestPayer.ToString()));
            }

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

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

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

            if (uploadPartRequest.IsSetPartNumber())
            {
                request.AddSubResource("partNumber", S3Transforms.ToStringValue(uploadPartRequest.PartNumber));
            }
            if (uploadPartRequest.IsSetUploadId())
            {
                request.AddSubResource("uploadId", S3Transforms.ToStringValue(uploadPartRequest.UploadId));
            }

            if (uploadPartRequest.InputStream != null)
            {
                // Wrap input stream in partial wrapper (to upload only part of the stream)
                var partialStream = new PartialWrapperStream(uploadPartRequest.InputStream, uploadPartRequest.PartSize);
                if (partialStream.Length > 0)
                {
                    request.UseChunkEncoding = uploadPartRequest.UseChunkEncoding;
                }
                if (!request.Headers.ContainsKey(HeaderKeys.ContentLengthHeader))
                {
                    request.Headers.Add(HeaderKeys.ContentLengthHeader, partialStream.Length.ToString(CultureInfo.InvariantCulture));
                }

                // Wrap input stream in MD5Stream; after this we can no longer seek or position the stream
                var hashStream = new MD5Stream(partialStream, null, partialStream.Length);
                uploadPartRequest.InputStream = hashStream;
            }

            request.ContentStream = uploadPartRequest.InputStream;

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

            return(request);
        }
        public IRequest Marshall(GetObjectRequest getObjectRequest)
        {
            if (string.IsNullOrEmpty(getObjectRequest.Key))
            {
                throw new System.ArgumentException("Key is a required property and must be set before making this call.", "GetObjectRequest.Key");
            }

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

            request.HttpMethod = "GET";

            if (getObjectRequest.IsSetEtagToMatch())
            {
                request.Headers.Add(HeaderKeys.IfMatchHeader, S3Transforms.ToStringValue(getObjectRequest.EtagToMatch));
            }

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

            if (getObjectRequest.IsSetEtagToNotMatch())
            {
                request.Headers.Add(HeaderKeys.IfNoneMatchHeader, S3Transforms.ToStringValue(getObjectRequest.EtagToNotMatch));
            }

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

            if (getObjectRequest.IsSetByteRange())
            {
                request.Headers.Add(HeaderKeys.RangeHeader, getObjectRequest.ByteRange.FormattedByteRange);
            }

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

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

            var headerOverrides = getObjectRequest.ResponseHeaderOverrides;

            if (headerOverrides.CacheControl != null)
            {
                request.Parameters.Add("response-cache-control", S3Transforms.ToStringValue(headerOverrides.CacheControl));
            }
            if (headerOverrides.ContentDisposition != null)
            {
                request.Parameters.Add("response-content-disposition", S3Transforms.ToStringValue(headerOverrides.ContentDisposition));
            }
            if (headerOverrides.ContentEncoding != null)
            {
                request.Parameters.Add("response-content-encoding", S3Transforms.ToStringValue(headerOverrides.ContentEncoding));
            }
            if (headerOverrides.ContentLanguage != null)
            {
                request.Parameters.Add("response-content-language", S3Transforms.ToStringValue(headerOverrides.ContentLanguage));
            }
            if (headerOverrides.ContentType != null)
            {
                request.Parameters.Add("response-content-type", S3Transforms.ToStringValue(headerOverrides.ContentType));
            }
            if (getObjectRequest.IsSetResponseExpires())
            {
                request.Parameters.Add("response-expires", S3Transforms.ToStringValue(getObjectRequest.ResponseExpires));
            }
            if (getObjectRequest.IsSetVersionId())
            {
                request.AddSubResource("versionId", S3Transforms.ToStringValue(getObjectRequest.VersionId));
            }

            request.UseQueryString = true;

            return(request);
        }
        public IRequest Marshall(CopyPartRequest copyPartRequest)
        {
            IRequest request        = new DefaultRequest(copyPartRequest, "AmazonS3");
            var      sourceKey      = AmazonS3Util.RemoveLeadingSlash(copyPartRequest.SourceKey);
            var      destinationKey = AmazonS3Util.RemoveLeadingSlash(copyPartRequest.DestinationKey);

            request.HttpMethod = "PUT";

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

            if (copyPartRequest.IsSetETagToMatch())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfMatchHeader, AWSSDKUtils.Join(copyPartRequest.ETagToMatch));
            }

            if (copyPartRequest.IsSetETagToNotMatch())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfNoneMatchHeader, AWSSDKUtils.Join(copyPartRequest.ETagsToNotMatch));
            }

            if (copyPartRequest.IsSetModifiedSinceDate())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfModifiedSinceHeader, copyPartRequest.ModifiedSinceDate.ToUniversalTime().ToString(AWSSDKUtils.GMTDateFormat, CultureInfo.InvariantCulture));
            }

            if (copyPartRequest.IsSetUnmodifiedSinceDate())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfUnmodifiedSinceHeader, copyPartRequest.UnmodifiedSinceDate.ToUniversalTime().ToString(AWSSDKUtils.GMTDateFormat, CultureInfo.InvariantCulture));
            }

            if (copyPartRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, copyPartRequest.ServerSideEncryptionCustomerMethod);
            }

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

            if (copyPartRequest.IsSetCopySourceServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerAlgorithmHeader, copyPartRequest.CopySourceServerSideEncryptionCustomerMethod);
            }

            if (copyPartRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerKeyHeader, copyPartRequest.CopySourceServerSideEncryptionCustomerProvidedKey);
                if (copyPartRequest.IsSetCopySourceServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerKeyMD5Header, copyPartRequest.CopySourceServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzCopySourceSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(copyPartRequest.CopySourceServerSideEncryptionCustomerProvidedKey));
                }
            }

            if (copyPartRequest.IsSetFirstByte() && copyPartRequest.IsSetLastByte())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceRangeHeader, ConstructCopySourceRangeHeader(copyPartRequest.FirstByte, copyPartRequest.LastByte));
            }

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

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

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

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

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

            request.AddSubResource("partNumber", S3Transforms.ToStringValue(copyPartRequest.PartNumber));
            request.AddSubResource("uploadId", S3Transforms.ToStringValue(copyPartRequest.UploadId));

            request.UseQueryString = true;

            return(request);
        }
        public IRequest Marshall(UploadPartRequest uploadPartRequest)
        {
            //IL_0006: Unknown result type (might be due to invalid IL or missing references)
            //IL_000c: Expected O, but got Unknown
            //IL_0160: Unknown result type (might be due to invalid IL or missing references)
            //IL_0166: Expected O, but got Unknown
            //IL_01b4: Unknown result type (might be due to invalid IL or missing references)
            //IL_01ba: Expected O, but got Unknown
            IRequest val = new DefaultRequest(uploadPartRequest, "AmazonS3");

            val.set_HttpMethod("PUT");
            if (uploadPartRequest.IsSetMD5Digest())
            {
                val.get_Headers()["Content-MD5"] = uploadPartRequest.MD5Digest;
            }
            if (uploadPartRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-algorithm", ConstantClass.op_Implicit(uploadPartRequest.ServerSideEncryptionCustomerMethod));
            }
            if (uploadPartRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-key", uploadPartRequest.ServerSideEncryptionCustomerProvidedKey);
                if (uploadPartRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", uploadPartRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", AmazonS3Util.ComputeEncodedMD5FromEncodedString(uploadPartRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (uploadPartRequest.IsSetRequestPayer())
            {
                val.get_Headers().Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(((object)uploadPartRequest.RequestPayer).ToString()));
            }
            val.set_ResourcePath(string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(uploadPartRequest.BucketName), S3Transforms.ToStringValue(uploadPartRequest.Key)));
            if (uploadPartRequest.IsSetPartNumber())
            {
                val.AddSubResource("partNumber", S3Transforms.ToStringValue(uploadPartRequest.PartNumber));
            }
            if (uploadPartRequest.IsSetUploadId())
            {
                val.AddSubResource("uploadId", S3Transforms.ToStringValue(uploadPartRequest.UploadId));
            }
            if (uploadPartRequest.InputStream != null)
            {
                PartialWrapperStream val2 = new PartialWrapperStream(uploadPartRequest.InputStream, uploadPartRequest.PartSize);
                if (((Stream)val2).Length > 0)
                {
                    val.set_UseChunkEncoding(true);
                }
                if (!val.get_Headers().ContainsKey("Content-Length"))
                {
                    val.get_Headers().Add("Content-Length", ((Stream)val2).Length.ToString(CultureInfo.InvariantCulture));
                }
                MD5Stream val3 = uploadPartRequest.InputStream = (Stream) new MD5Stream((Stream)val2, (byte[])null, ((Stream)val2).Length);
            }
            val.set_ContentStream(uploadPartRequest.InputStream);
            if (!val.get_Headers().ContainsKey("Content-Type"))
            {
                val.get_Headers().Add("Content-Type", "text/plain");
            }
            return(val);
        }
Esempio n. 11
0
        public IRequest Marshall(GetObjectRequest getObjectRequest)
        {
            //IL_0023: Unknown result type (might be due to invalid IL or missing references)
            //IL_0029: Expected O, but got Unknown
            if (string.IsNullOrEmpty(getObjectRequest.Key))
            {
                throw new ArgumentException("Key is a required property and must be set before making this call.", "GetObjectRequest.Key");
            }
            IRequest val = new DefaultRequest(getObjectRequest, "AmazonS3");

            val.set_HttpMethod("GET");
            if (getObjectRequest.IsSetEtagToMatch())
            {
                val.get_Headers().Add("If-Match", S3Transforms.ToStringValue(getObjectRequest.EtagToMatch));
            }
            if (getObjectRequest.IsSetModifiedSinceDate())
            {
                val.get_Headers().Add("If-Modified-Since", S3Transforms.ToStringValue(getObjectRequest.ModifiedSinceDate));
            }
            if (getObjectRequest.IsSetEtagToNotMatch())
            {
                val.get_Headers().Add("If-None-Match", S3Transforms.ToStringValue(getObjectRequest.EtagToNotMatch));
            }
            if (getObjectRequest.IsSetUnmodifiedSinceDate())
            {
                val.get_Headers().Add("If-Unmodified-Since", S3Transforms.ToStringValue(getObjectRequest.UnmodifiedSinceDate));
            }
            if (getObjectRequest.IsSetByteRange())
            {
                val.get_Headers().Add("Range", getObjectRequest.ByteRange.FormattedByteRange);
            }
            if (getObjectRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-algorithm", ConstantClass.op_Implicit(getObjectRequest.ServerSideEncryptionCustomerMethod));
            }
            if (getObjectRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-key", getObjectRequest.ServerSideEncryptionCustomerProvidedKey);
                if (getObjectRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", getObjectRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", AmazonS3Util.ComputeEncodedMD5FromEncodedString(getObjectRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (getObjectRequest.IsSetRequestPayer())
            {
                val.get_Headers().Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(((object)getObjectRequest.RequestPayer).ToString()));
            }
            val.set_ResourcePath(string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(getObjectRequest.BucketName), S3Transforms.ToStringValue(getObjectRequest.Key)));
            ResponseHeaderOverrides responseHeaderOverrides = getObjectRequest.ResponseHeaderOverrides;

            if (responseHeaderOverrides.CacheControl != null)
            {
                val.get_Parameters().Add("response-cache-control", S3Transforms.ToStringValue(responseHeaderOverrides.CacheControl));
            }
            if (responseHeaderOverrides.ContentDisposition != null)
            {
                val.get_Parameters().Add("response-content-disposition", S3Transforms.ToStringValue(responseHeaderOverrides.ContentDisposition));
            }
            if (responseHeaderOverrides.ContentEncoding != null)
            {
                val.get_Parameters().Add("response-content-encoding", S3Transforms.ToStringValue(responseHeaderOverrides.ContentEncoding));
            }
            if (responseHeaderOverrides.ContentLanguage != null)
            {
                val.get_Parameters().Add("response-content-language", S3Transforms.ToStringValue(responseHeaderOverrides.ContentLanguage));
            }
            if (responseHeaderOverrides.ContentType != null)
            {
                val.get_Parameters().Add("response-content-type", S3Transforms.ToStringValue(responseHeaderOverrides.ContentType));
            }
            if (getObjectRequest.IsSetResponseExpires())
            {
                val.get_Parameters().Add("response-expires", S3Transforms.ToStringValue(getObjectRequest.ResponseExpires));
            }
            if (getObjectRequest.IsSetVersionId())
            {
                val.AddSubResource("versionId", S3Transforms.ToStringValue(getObjectRequest.VersionId));
            }
            if (getObjectRequest.IsSetPartNumber())
            {
                val.AddSubResource("partNumber", S3Transforms.ToStringValue(getObjectRequest.PartNumber.Value));
            }
            val.set_UseQueryString(true);
            return(val);
        }
        public IRequest Marshall(GetObjectMetadataRequest headObjectRequest)
        {
            //IL_0023: Unknown result type (might be due to invalid IL or missing references)
            //IL_0029: Expected O, but got Unknown
            if (string.IsNullOrEmpty(headObjectRequest.Key))
            {
                throw new ArgumentException("Key is a required property and must be set before making this call.", "GetObjectMetadataRequest.Key");
            }
            IRequest val = new DefaultRequest(headObjectRequest, "AmazonS3");

            val.set_HttpMethod("HEAD");
            if (headObjectRequest.IsSetEtagToMatch())
            {
                val.get_Headers().Add("If-Match", S3Transforms.ToStringValue(headObjectRequest.EtagToMatch));
            }
            if (headObjectRequest.IsSetModifiedSinceDate())
            {
                val.get_Headers().Add("If-Modified-Since", S3Transforms.ToStringValue(headObjectRequest.ModifiedSinceDate));
            }
            if (headObjectRequest.IsSetEtagToNotMatch())
            {
                val.get_Headers().Add("If-None-Match", S3Transforms.ToStringValue(headObjectRequest.EtagToNotMatch));
            }
            if (headObjectRequest.IsSetUnmodifiedSinceDate())
            {
                val.get_Headers().Add("If-Unmodified-Since", S3Transforms.ToStringValue(headObjectRequest.UnmodifiedSinceDate));
            }
            if (headObjectRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-algorithm", ConstantClass.op_Implicit(headObjectRequest.ServerSideEncryptionCustomerMethod));
            }
            if (headObjectRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                val.get_Headers().Add("x-amz-server-side-encryption-customer-key", headObjectRequest.ServerSideEncryptionCustomerProvidedKey);
                if (headObjectRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", headObjectRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    val.get_Headers().Add("x-amz-server-side-encryption-customer-key-MD5", AmazonS3Util.ComputeEncodedMD5FromEncodedString(headObjectRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (headObjectRequest.IsSetRequestPayer())
            {
                val.get_Headers().Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(((object)headObjectRequest.RequestPayer).ToString()));
            }
            val.set_ResourcePath(string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(headObjectRequest.BucketName), S3Transforms.ToStringValue(headObjectRequest.Key)));
            if (headObjectRequest.IsSetVersionId())
            {
                val.AddSubResource("versionId", S3Transforms.ToStringValue(headObjectRequest.VersionId));
            }
            if (headObjectRequest.IsSetPartNumber())
            {
                val.AddSubResource("partNumber", S3Transforms.ToStringValue(headObjectRequest.PartNumber.Value));
            }
            val.set_UseQueryString(true);
            return(val);
        }
Esempio n. 13
0
        public IRequest Marshall(UploadPartRequest uploadPartRequest)
        {
            IRequest request = new DefaultRequest(uploadPartRequest, "AmazonS3");

            request.HttpMethod = "PUT";

            if (uploadPartRequest.IsSetChecksumAlgorithm())
            {
                request.Headers.Add(S3Constants.AmzHeaderSdkChecksumAlgorithm, S3Transforms.ToStringValue(uploadPartRequest.ChecksumAlgorithm));
            }

            if (uploadPartRequest.IsSetChecksumCRC32())
            {
                request.Headers["x-amz-checksum-crc32"] = S3Transforms.ToStringValue(uploadPartRequest.ChecksumCRC32);
            }

            if (uploadPartRequest.IsSetChecksumCRC32C())
            {
                request.Headers["x-amz-checksum-crc32c"] = S3Transforms.ToStringValue(uploadPartRequest.ChecksumCRC32C);
            }

            if (uploadPartRequest.IsSetChecksumSHA1())
            {
                request.Headers["x-amz-checksum-sha1"] = S3Transforms.ToStringValue(uploadPartRequest.ChecksumSHA1);
            }

            if (uploadPartRequest.IsSetChecksumSHA256())
            {
                request.Headers["x-amz-checksum-sha256"] = S3Transforms.ToStringValue(uploadPartRequest.ChecksumSHA256);
            }

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

            if (uploadPartRequest.IsSetServerSideEncryptionCustomerMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader, uploadPartRequest.ServerSideEncryptionCustomerMethod);
            }
            if (uploadPartRequest.IsSetServerSideEncryptionCustomerProvidedKey())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyHeader, uploadPartRequest.ServerSideEncryptionCustomerProvidedKey);
                if (uploadPartRequest.IsSetServerSideEncryptionCustomerProvidedKeyMD5())
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, uploadPartRequest.ServerSideEncryptionCustomerProvidedKeyMD5);
                }
                else
                {
                    request.Headers.Add(HeaderKeys.XAmzSSECustomerKeyMD5Header, AmazonS3Util.ComputeEncodedMD5FromEncodedString(uploadPartRequest.ServerSideEncryptionCustomerProvidedKey));
                }
            }
            if (uploadPartRequest.IsSetRequestPayer())
            {
                request.Headers.Add(S3Constants.AmzHeaderRequestPayer, S3Transforms.ToStringValue(uploadPartRequest.RequestPayer.ToString()));
            }

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

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

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

            if (uploadPartRequest.IsSetPartNumber())
            {
                request.AddSubResource("partNumber", S3Transforms.ToStringValue(uploadPartRequest.PartNumber));
            }
            if (uploadPartRequest.IsSetUploadId())
            {
                request.AddSubResource("uploadId", S3Transforms.ToStringValue(uploadPartRequest.UploadId));
            }

            if (uploadPartRequest.InputStream != null)
            {
                // Wrap input stream in partial wrapper (to upload only part of the stream)
                var partialStream = new PartialWrapperStream(uploadPartRequest.InputStream, uploadPartRequest.PartSize);
                if (partialStream.Length > 0 && !(uploadPartRequest.DisablePayloadSigning ?? false))
                {
                    request.UseChunkEncoding = uploadPartRequest.UseChunkEncoding;
                }
                if (!request.Headers.ContainsKey(HeaderKeys.ContentLengthHeader))
                {
                    request.Headers.Add(HeaderKeys.ContentLengthHeader, partialStream.Length.ToString(CultureInfo.InvariantCulture));
                }

                request.DisablePayloadSigning = uploadPartRequest.DisablePayloadSigning;

                // Calculate Content-MD5 if not already set
                if (!uploadPartRequest.IsSetMD5Digest() && uploadPartRequest.CalculateContentMD5Header)
                {
                    string md5 = AmazonS3Util.GenerateMD5ChecksumForStream(partialStream);
                    if (!string.IsNullOrEmpty(md5))
                    {
                        request.Headers[HeaderKeys.ContentMD5Header] = md5;
                    }
                }

                if (!(uploadPartRequest.DisableMD5Stream ?? AWSConfigsS3.DisableMD5Stream))
                {
                    // Wrap input stream in MD5Stream; after this we can no longer seek or position the stream
                    var hashStream = new MD5Stream(partialStream, null, partialStream.Length);
                    uploadPartRequest.InputStream = hashStream;
                }
                else
                {
                    uploadPartRequest.InputStream = partialStream;
                }
            }

            request.ContentStream = uploadPartRequest.InputStream;
            ChecksumUtils.SetRequestChecksum(request, uploadPartRequest.ChecksumAlgorithm, fallbackToMD5: false);

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

            return(request);
        }
Esempio n. 14
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);
        }
Esempio n. 15
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);
        }
Esempio n. 16
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);
        }
        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);
        }
        public IRequest Marshall(UploadPartRequest uploadPartRequest)
        {
            IRequest request = new DefaultRequest(uploadPartRequest, "AmazonS3");

            request.HttpMethod = "PUT";

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

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

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

            if (uploadPartRequest.IsSetPartNumber())
            {
                request.AddSubResource("partNumber", S3Transforms.ToStringValue(uploadPartRequest.PartNumber));
            }
            if (uploadPartRequest.IsSetUploadId())
            {
                request.AddSubResource("uploadId", S3Transforms.ToStringValue(uploadPartRequest.UploadId));
            }

            if (uploadPartRequest.InputStream != null)
            {
                // Wrap input stream in partial wrapper (to upload only part of the stream)
                var partialStream = new PartialWrapperStream(uploadPartRequest.InputStream, uploadPartRequest.PartSize);
                if (partialStream.Length > 0)
                {
                    request.UseChunkEncoding = true;
                }
                if (!request.Headers.ContainsKey(HeaderKeys.ContentLengthHeader))
                {
                    request.Headers.Add(HeaderKeys.ContentLengthHeader, partialStream.Length.ToString(CultureInfo.InvariantCulture));
                }

                // Wrap input stream in MD5Stream; after this we can no longer seek or position the stream
                var hashStream = new MD5Stream(partialStream, null, partialStream.Length);
                uploadPartRequest.InputStream = hashStream;
            }

            request.ContentStream = uploadPartRequest.InputStream;

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

            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);
        }
Esempio n. 20
0
        public IRequest Marshall(SelectObjectContentRequest selectObjectContentRequest)
        {
            // Required Parameters
            // Bucket
            if (string.IsNullOrEmpty(selectObjectContentRequest.Bucket))
            {
                throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.Bucket));
            }
            // Key
            if (string.IsNullOrEmpty(selectObjectContentRequest.Key))
            {
                throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.Key));
            }
            // Expression
            if (string.IsNullOrEmpty(selectObjectContentRequest.Expression))
            {
                throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.Expression));
            }
            // ExpressionType
            if (!selectObjectContentRequest.IsSetExpressionType())
            {
                throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.ExpressionType));
            }
            // InputSerialization
            if (!selectObjectContentRequest.IsSetInputSerialization())
            {
                throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.InputSerialization));
            }
            // OutputSerialization
            if (!selectObjectContentRequest.IsSetOutputSerialization())
            {
                throw ConstructExceptionArgumentRequired(nameof(selectObjectContentRequest.OutputSerialization));
            }

            var request = new DefaultRequest(selectObjectContentRequest, "AmazonS3")
            {
                HttpMethod   = "POST",
                ResourcePath =
                    string.Format(CultureInfo.InvariantCulture, "/{0}/{1}", S3Transforms.ToStringValue(selectObjectContentRequest.Bucket), S3Transforms.ToStringValue(selectObjectContentRequest.Key)),
                UseQueryString = true,
            };

            // Headers
            if (selectObjectContentRequest.IsSetServerSideCustomerEncryptionMethod())
            {
                request.Headers.Add(HeaderKeys.XAmzSSECustomerAlgorithmHeader,
                                    selectObjectContentRequest.ServerSideCustomerEncryptionMethod);
            }

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

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

            // Subresources
            request.AddSubResource("select");
            request.AddSubResource("select-type", "2");

            // Parameters
            using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                var xmlWriterSettings = new XmlWriterSettings()
                {
                    Encoding           = Encoding.UTF8,
                    OmitXmlDeclaration = true,
                    NewLineHandling    = NewLineHandling.None
                };
                using (var xmlWriter = XmlWriter.Create(stringWriter, xmlWriterSettings))
                {
                    xmlWriter.WriteStartElement("SelectRequest");
                    xmlWriter.WriteElementString("Expression",
                                                 S3Transforms.ToXmlStringValue(selectObjectContentRequest.Expression));
                    xmlWriter.WriteElementString("ExpressionType",
                                                 S3Transforms.ToXmlStringValue(selectObjectContentRequest.ExpressionType.Value));
                    selectObjectContentRequest.InputSerialization.Marshall("InputSerialization", xmlWriter);
                    selectObjectContentRequest.OutputSerialization.Marshall("OutputSerialization", xmlWriter);
                    xmlWriter.WriteStartElement("RequestProgress");
                    xmlWriter.WriteElementString("Enabled",
                                                 selectObjectContentRequest.RequestProgress.GetValueOrDefault(false).ToString()
                                                 .ToUpperInvariant());
                    if (selectObjectContentRequest.IsSetScanRange())
                    {
                        selectObjectContentRequest.ScanRange.Marshall("ScanRange", xmlWriter);
                    }
                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndElement();
                }

                try
                {
                    var content = stringWriter.ToString();
                    request.Content = Encoding.UTF8.GetBytes(content);
                    request.Headers[HeaderKeys.ContentTypeHeader] = "application/xml";

                    var checksum = AWSSDKUtils.GenerateChecksumForContent(content, true);
                    request.Headers[HeaderKeys.ContentMD5Header] = checksum;
                }
                catch (EncoderFallbackException e)
                {
                    throw new AmazonServiceException("Unable to marshall request to XML", e);
                }
            }

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

            request.HttpMethod = "PUT";

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

            if (copyPartRequest.IsSetETagToMatch())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfMatchHeader, AWSSDKUtils.Join(copyPartRequest.ETagToMatch));
            }

            if (copyPartRequest.IsSetETagToNotMatch())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfNoneMatchHeader, AWSSDKUtils.Join(copyPartRequest.ETagsToNotMatch));
            }

            if (copyPartRequest.IsSetModifiedSinceDate())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfModifiedSinceHeader, copyPartRequest.ModifiedSinceDate.ToUniversalTime().ToString(AWSSDKUtils.GMTDateFormat, CultureInfo.InvariantCulture));
            }

            if (copyPartRequest.IsSetUnmodifiedSinceDate())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceIfUnmodifiedSinceHeader, copyPartRequest.UnmodifiedSinceDate.ToUniversalTime().ToString(AWSSDKUtils.GMTDateFormat, CultureInfo.InvariantCulture));
            }

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

            if (copyPartRequest.IsSetFirstByte() && copyPartRequest.IsSetLastByte())
            {
                request.Headers.Add(HeaderKeys.XAmzCopySourceRangeHeader, ConstructCopySourceRangeHeader(copyPartRequest.FirstByte, copyPartRequest.LastByte));
            }

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

            request.AddSubResource("partNumber", S3Transforms.ToStringValue(copyPartRequest.PartNumber));
            request.AddSubResource("uploadId", S3Transforms.ToStringValue(copyPartRequest.UploadId));

            request.UseQueryString = true;

            return(request);
        }
Esempio n. 22
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);
        }