/* * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using System; using System.Collections.Generic; using System.Xml.Serialization; using System.Text; using System.IO; using Amazon.Runtime; using Amazon.Runtime.Internal; namespace Amazon.S3.Model { /// /// The parameters to request upload of a part in a multipart upload operation. /// /// /// /// If PartSize is not specified then the rest of the content from the file /// or stream will be sent to Amazon S3. /// /// /// You must set either the FilePath or InputStream. If FilePath is set then the FilePosition /// property must be set. /// /// public partial class UploadPartRequest : AmazonWebServiceRequest { private Stream inputStream; private string bucketName; private string key; private int? partNumber; private string uploadId; private long? partSize; private string md5Digest; private ServerSideEncryptionCustomerMethod serverSideCustomerEncryption; private string serverSideEncryptionCustomerProvidedKey; private string serverSideEncryptionCustomerProvidedKeyMD5; private string filePath; private long? filePosition; private bool useChunkEncoding = true; private bool lastPart; private RequestPayer requestPayer; internal int IVSize { get; set; } /// /// Caller needs to set this to true when uploading the last part. This property only needs to be set /// when using the AmazonS3EncryptionClient. /// public bool IsLastPart { get { return this.lastPart; } set { this.lastPart = value; } } /// /// Input stream for the request; content for the request will be read from the stream. /// public Stream InputStream { get { return this.inputStream; } set { this.inputStream = value; } } // Check to see if Body property is set internal bool IsSetInputStream() { return this.inputStream != null; } /// /// The name of the bucket containing the object to receive the part. /// public string BucketName { get { return this.bucketName; } set { this.bucketName = value; } } // Check to see if Bucket property is set internal bool IsSetBucketName() { return this.bucketName != null; } /// /// The key of the object. /// public string Key { get { return this.key; } set { this.key = value; } } // Check to see if Key property is set internal bool IsSetKey() { return this.key != null; } /// /// Part number of part being uploaded. /// /// public int PartNumber { get { return this.partNumber.GetValueOrDefault(); } set { this.partNumber = value; } } // Check to see if PartNumber property is set internal bool IsSetPartNumber() { return this.partNumber.HasValue; } /// /// The size of the part to be uploaded. /// public long PartSize { get { return this.partSize.GetValueOrDefault(); } set { this.partSize = value; } } /// /// Checks if PartSize property is set. /// /// true if PartSize property is set. internal bool IsSetPartSize() { return this.partSize.HasValue; } /// /// Upload ID identifying the multipart upload whose part is being uploaded. /// /// public string UploadId { get { return this.uploadId; } set { this.uploadId = value; } } // Check to see if UploadId property is set internal bool IsSetUploadId() { return this.uploadId != null; } /// /// An MD5 digest for the part. /// public string MD5Digest { get { return this.md5Digest; } set { this.md5Digest = value; } } /// /// The Server-side encryption algorithm to be used with the customer provided key. /// /// public ServerSideEncryptionCustomerMethod ServerSideEncryptionCustomerMethod { get { return this.serverSideCustomerEncryption; } set { this.serverSideCustomerEncryption = value; } } // Check to see if ServerSideEncryptionCustomerMethod property is set internal bool IsSetServerSideEncryptionCustomerMethod() { return this.serverSideCustomerEncryption != null && this.serverSideCustomerEncryption != ServerSideEncryptionCustomerMethod.None; } /// /// The base64-encoded encryption key for Amazon S3 to use to encrypt the object /// /// Using the encryption key you provide as part of your request Amazon S3 manages both the encryption, as it writes /// to disks, and decryption, when you access your objects. Therefore, you don't need to maintain any data encryption code. The only /// thing you do is manage the encryption keys you provide. /// /// /// When you retrieve an object, you must provide the same encryption key as part of your request. Amazon S3 first verifies /// the encryption key you provided matches, and then decrypts the object before returning the object data to you. /// /// /// Important: Amazon S3 does not store the encryption key you provide. /// /// public string ServerSideEncryptionCustomerProvidedKey { get { return this.serverSideEncryptionCustomerProvidedKey; } set { this.serverSideEncryptionCustomerProvidedKey = value; } } /// /// Checks if ServerSideEncryptionCustomerProvidedKey property is set. /// /// true if ServerSideEncryptionCustomerProvidedKey property is set. internal bool IsSetServerSideEncryptionCustomerProvidedKey() { return !System.String.IsNullOrEmpty(this.serverSideEncryptionCustomerProvidedKey); } /// /// The MD5 of the customer encryption key specified in the ServerSideEncryptionCustomerProvidedKey property. The MD5 is /// base 64 encoded. This field is optional, the SDK will calculate the MD5 if this is not set. /// public string ServerSideEncryptionCustomerProvidedKeyMD5 { get { return this.serverSideEncryptionCustomerProvidedKeyMD5; } set { this.serverSideEncryptionCustomerProvidedKeyMD5 = value; } } /// /// Checks if ServerSideEncryptionCustomerProvidedKeyMD5 property is set. /// /// true if ServerSideEncryptionCustomerProvidedKey property is set. internal bool IsSetServerSideEncryptionCustomerProvidedKeyMD5() { return !System.String.IsNullOrEmpty(this.serverSideEncryptionCustomerProvidedKeyMD5); } /// /// /// Full path and name of a file from which the content for the part is retrieved. /// /// /// For WinRT and Windows Phone this property must be in the form of "ms-appdata:///local/file.txt". /// /// public string FilePath { get { return this.filePath; } set { this.filePath = value; } } /// /// Checks if the FilePath property is set. /// /// true if FilePath property is set. internal bool IsSetFilePath() { return !string.IsNullOrEmpty(this.filePath); } /// /// Position in the file specified by FilePath from which to retrieve the content of the part. /// This field is required when a file path is specified. It is ignored when using the InputStream property. /// public long FilePosition { get { return this.filePosition.GetValueOrDefault(); } set { this.filePosition = value; } } /// /// If this value is set to true then a chunked encoding upload will be used for the request. /// Default: true. /// public bool UseChunkEncoding { get { return this.useChunkEncoding; } set { this.useChunkEncoding = value; } } /// /// Checks if the FilePosition property is set. /// /// true if FilePosition property is set. internal bool IsSetFilePosition() { return this.filePosition.HasValue; } /// /// Checks if the MD5Digest property is set. /// /// true if Md5Digest property is set. internal bool IsSetMD5Digest() { return !string.IsNullOrEmpty(this.md5Digest); } /// /// Attach a callback that will be called as data is being sent to the AWS Service. /// public EventHandler StreamTransferProgress { get { return ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)this).StreamUploadProgressCallback; } set { ((Amazon.Runtime.Internal.IAmazonWebServiceRequest)this).StreamUploadProgressCallback = value; } } /// /// Overriden to turn off sending SHA256 header. /// protected override bool IncludeSHA256Header { get { return false; } } /// /// Overriden to turn on Expect 100 continue. /// protected override bool Expect100Continue { get { return true; } } /// /// Confirms that the requester knows that she or he will be charged for the list objects request. /// Bucket owners need not specify this parameter in their requests. /// public RequestPayer RequestPayer { get { return this.requestPayer; } set { this.requestPayer = value; } } /// /// Checks to see if RequetsPayer is set. /// /// true, if RequestPayer property is set. internal bool IsSetRequestPayer() { return requestPayer != null; } } }