/*
* Copyright 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
{
///
/// Container for the parameters to the UploadPart operation.
/// Uploads a part in a multipart upload.
///
///
///
/// In this operation, you provide part data in your request. However, you have an option
/// to specify your existing Amazon S3 object as a data source for the part you are uploading.
/// To upload a part from an existing object, you use the UploadPartCopy
/// operation.
///
///
///
/// You must initiate a multipart upload (see CreateMultipartUpload)
/// before you can upload any part. In response to your initiate request, Amazon S3 returns
/// an upload ID, a unique identifier, that you must include in your upload part request.
///
///
///
/// Part numbers can be any number from 1 to 10,000, inclusive. A part number uniquely
/// identifies a part and also defines its position within the object being created. If
/// you upload a new part using the same part number that was used with a previous part,
/// the previously uploaded part is overwritten.
///
///
///
/// For information about maximum and minimum part sizes and other multipart upload specifications,
/// see Multipart
/// upload limits in the Amazon S3 User Guide.
///
///
///
/// To ensure that data is not corrupted when traversing the network, specify the Content-MD5
/// header in the upload part request. Amazon S3 checks the part data against the provided
/// MD5 value. If they do not match, Amazon S3 returns an error.
///
///
///
/// If the upload request is signed with Signature Version 4, then Amazon Web Services
/// S3 uses the x-amz-content-sha256
header as a checksum instead of Content-MD5
.
/// For more information see Authenticating
/// Requests: Using the Authorization Header (Amazon Web Services Signature Version 4).
///
///
///
///
/// Note: After you initiate multipart upload and upload one or more parts, you
/// must either complete or abort multipart upload in order to stop getting charged for
/// storage of the uploaded parts. Only after you either complete or abort multipart upload,
/// Amazon S3 frees up the parts storage and stops charging you for the parts storage.
///
///
///
/// For more information on multipart uploads, go to Multipart
/// Upload Overview in the Amazon S3 User Guide .
///
///
///
/// For information on the permissions required to use the multipart upload API, go to
/// Multipart
/// Upload and Permissions in the Amazon S3 User Guide.
///
///
///
/// You can optionally request server-side encryption where Amazon S3 encrypts your data
/// as it writes it to disks in its data centers and decrypts it for you when you access
/// it. You have the option of providing your own encryption key, or you can use the Amazon
/// Web Services managed encryption keys. If you choose to provide your own encryption
/// key, the request headers you provide in the request must match the headers you used
/// in the request to initiate the upload by using CreateMultipartUpload.
/// For more information, go to Using
/// Server-Side Encryption in the Amazon S3 User Guide.
///
///
///
/// Server-side encryption is supported by the S3 Multipart Upload actions. Unless you
/// are using a customer-provided encryption key, you don't need to specify the encryption
/// parameters in each UploadPart request. Instead, you only need to specify the server-side
/// encryption parameters in the initial Initiate Multipart request. For more information,
/// see CreateMultipartUpload.
///
///
///
/// If you requested server-side encryption using a customer-provided encryption key in
/// your initiate multipart upload request, you must provide identical encryption information
/// in each part upload using the following headers.
///
/// -
///
/// x-amz-server-side-encryption-customer-algorithm
///
///
-
///
/// x-amz-server-side-encryption-customer-key
///
///
-
///
/// x-amz-server-side-encryption-customer-key-MD5
///
///
///
/// UploadPart
has the following special errors:
///
/// -
-
///
/// Code: NoSuchUpload
///
///
-
///
/// Cause: The specified multipart upload does not exist. The upload ID might be invalid,
/// or the multipart upload might have been aborted or completed.
///
///
-
///
/// HTTP Status Code: 404 Not Found
///
///
-
///
/// SOAP Fault Code Prefix: Client
///
///
///
/// The following operations are related to UploadPart
:
///
///
///
public partial class UploadPartRequest : AmazonWebServiceRequest
{
private Stream inputStream;
private string bucketName;
private ChecksumAlgorithm _checksumAlgorithm;
private string _checksumCRC32;
private string _checksumCRC32C;
private string _checksumSHA1;
private string _checksumSHA256;
private string md5Digest;
private string expectedBucketOwner;
private string key;
private int? partNumber;
private RequestPayer requestPayer;
private ServerSideEncryptionCustomerMethod serverSideCustomerEncryption;
private string serverSideEncryptionCustomerProvidedKey;
private string serverSideEncryptionCustomerProvidedKeyMD5;
private string uploadId;
private long? partSize;
private string filePath;
private long? filePosition;
private bool useChunkEncoding = true;
private bool lastPart;
private bool calculateContentMD5Header = false;
///
/// 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;
}
///
/// Gets and sets the property BucketName.
///
/// The name of the bucket to which the multipart upload was initiated.
///
///
///
/// When using this action with an access point, you must direct requests to the access
/// point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com.
/// When using this action with an access point through the Amazon Web Services SDKs,
/// you provide the access point ARN in place of the bucket name. For more information
/// about access point ARNs, see Using
/// access points in the Amazon S3 User Guide.
///
///
///
/// When you use this action with Amazon S3 on Outposts, you must direct requests to the
/// S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com
.
/// When you use this action with S3 on Outposts through the Amazon Web Services SDKs,
/// you provide the Outposts access point ARN in place of the bucket name. For more information
/// about S3 on Outposts ARNs, see What
/// is S3 on Outposts? in the Amazon S3 User Guide.
///
///
public string BucketName
{
get { return this.bucketName; }
set { this.bucketName = value; }
}
// Check to see if BucketName property is set
internal bool IsSetBucketName()
{
return this.bucketName != null;
}
///
/// Gets and sets the property ChecksumAlgorithm.
///
/// Indicates the algorithm used to create the checksum for the object. Amazon S3 will
/// fail the request with a 400 error if there is no checksum associated with the object.
/// For more information, see
/// Checking object integrity in the Amazon S3 User Guide.
///
///
///
/// If you provide an individual checksum, Amazon S3 will ignore any provided ChecksumAlgorithm
.
///
///
public ChecksumAlgorithm ChecksumAlgorithm
{
get { return this._checksumAlgorithm; }
set { this._checksumAlgorithm = value; }
}
// Check to see if ChecksumAlgorithm property is set
internal bool IsSetChecksumAlgorithm()
{
return this._checksumAlgorithm != null;
}
///
/// Gets and sets the property ChecksumCRC32.
///
/// This header can be used as a data integrity check to verify that the data received
/// is the same data that was originally sent. This specifies the base64-encoded, 32-bit
/// CRC32 checksum of the object. For more information, see
/// Checking object integrity in the Amazon S3 User Guide.
///
///
public string ChecksumCRC32
{
get { return this._checksumCRC32; }
set { this._checksumCRC32 = value; }
}
// Check to see if ChecksumCRC32 property is set
internal bool IsSetChecksumCRC32()
{
return this._checksumCRC32 != null;
}
///
/// Gets and sets the property ChecksumCRC32C.
///
/// This header can be used as a data integrity check to verify that the data received
/// is the same data that was originally sent. This specifies the base64-encoded, 32-bit
/// CRC32C checksum of the object. For more information, see
/// Checking object integrity in the Amazon S3 User Guide.
///
///
public string ChecksumCRC32C
{
get { return this._checksumCRC32C; }
set { this._checksumCRC32C = value; }
}
// Check to see if ChecksumCRC32C property is set
internal bool IsSetChecksumCRC32C()
{
return this._checksumCRC32C != null;
}
///
/// Gets and sets the property ChecksumSHA1.
///
/// This header can be used as a data integrity check to verify that the data received
/// is the same data that was originally sent. This specifies the base64-encoded, 160-bit
/// SHA-1 digest of the object. For more information, see
/// Checking object integrity in the Amazon S3 User Guide.
///
///
public string ChecksumSHA1
{
get { return this._checksumSHA1; }
set { this._checksumSHA1 = value; }
}
// Check to see if ChecksumSHA1 property is set
internal bool IsSetChecksumSHA1()
{
return this._checksumSHA1 != null;
}
///
/// Gets and sets the property ChecksumSHA256.
///
/// This header can be used as a data integrity check to verify that the data received
/// is the same data that was originally sent. This specifies the base64-encoded, 256-bit
/// SHA-256 digest of the object. For more information, see
/// Checking object integrity in the Amazon S3 User Guide.
///
///
public string ChecksumSHA256
{
get { return this._checksumSHA256; }
set { this._checksumSHA256 = value; }
}
// Check to see if ChecksumSHA256 property is set
internal bool IsSetChecksumSHA256()
{
return this._checksumSHA256 != null;
}
///
/// Gets and sets the property ExpectedBucketOwner.
///
/// The account ID of the expected bucket owner. If the bucket is owned by a different
/// account, the request will fail with an HTTP 403 (Access Denied)
error.
///
///
public string ExpectedBucketOwner
{
get { return this.expectedBucketOwner; }
set { this.expectedBucketOwner = value; }
}
///
/// Checks to see if ExpectedBucketOwner is set.
///
/// true, if ExpectedBucketOwner property is set.
internal bool IsSetExpectedBucketOwner()
{
return !String.IsNullOrEmpty(this.expectedBucketOwner);
}
///
/// The key of the object.
///
///
/// This property will be used as part of the resource path of the HTTP request. In .NET the System.Uri class
/// is used to construct the uri for the request. The System.Uri class will canonicalize the uri string by compacting characters like "..". /// For example an object key of "foo/../bar/file.txt" will be transformed into "bar/file.txt" because the ".."
/// is interpreted as use parent directory. For further information view the documentation for
/// the Uri class: https://docs.microsoft.com/en-us/dotnet/api/system.uri
///
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;
}
///
/// Gets and sets the property PartNumber.
///
/// Part number of part being uploaded. This is a positive integer between 1 and 10,000.
///
///
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;
}
///
/// Confirms that the requester knows that she or he will be charged for the request.
/// Bucket owners need not specify this parameter in their requests.
///
public RequestPayer RequestPayer
{
get { return this.requestPayer; }
set { this.requestPayer = value; }
}
// Check to see if RequestPayer property is set
internal bool IsSetRequestPayer()
{
return requestPayer != null;
}
///
/// The Server-side encryption algorithm to be used with the customer provided key.
///
/// Specifies the algorithm to use to when encrypting the object (for example, AES256).
///
///
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.
///
///
[AWSProperty(Sensitive=true)]
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);
}
///
/// 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;
}
///
/// 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; }
}
///
/// WARNING: Setting DisableMD5Stream to true disables the MD5 data integrity check
/// on this request.
/// When true, MD5Stream will not be used in the upload request. This may increase
/// upload performance under high CPU loads. The default value is null. When null, the
/// AWSConfigsS3.DisableMD5Stream property value will be used.
/// MD5Stream, SigV4 payload signing, and HTTPS each provide some data integrity
/// verification. If DisableMD5Stream is true and DisablePayloadSigning is true, then the
/// possibility of data corruption is completely dependant on HTTPS being the only remaining
/// source of data integrity verification.
///
public bool? DisableMD5Stream { get; set; }
///
/// An MD5 digest for the part.
///
public string MD5Digest
{
get { return this.md5Digest; }
set { this.md5Digest = value; }
}
///
/// Checks if the MD5Digest property is set.
///
/// true if Md5Digest property is set.
internal bool IsSetMD5Digest()
{
return !string.IsNullOrEmpty(this.md5Digest);
}
///
/// 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;
}
///
///
/// 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; }
}
///
/// WARNING: Setting DisablePayloadSigning to true disables the SigV4 payload signing
/// data integrity check on this request.
/// If using SigV4, the DisablePayloadSigning flag controls if the payload should be
/// signed on a request by request basis. By default this flag is null which will use the
/// default client behavior. The default client behavior is to sign the payload. When
/// DisablePayloadSigning is true, the request will be signed with an UNSIGNED-PAYLOAD value.
/// Setting DisablePayloadSigning to true requires that the request is sent over a HTTPS
/// connection.
/// Under certain circumstances, such as uploading to S3 while using MD5 hashing, it may
/// be desireable to use UNSIGNED-PAYLOAD to decrease signing CPU usage. This flag only applies
/// to Amazon S3 PutObject and UploadPart requests.
/// MD5Stream, SigV4 payload signing, and HTTPS each provide some data integrity
/// verification. If DisableMD5Stream is true and DisablePayloadSigning is true, then the
/// possibility of data corruption is completely dependant on HTTPS being the only remaining
/// source of data integrity verification.
///
public bool? DisablePayloadSigning { get; set; }
///
/// Checks if the FilePosition property is set.
///
/// true if FilePosition property is set.
internal bool IsSetFilePosition()
{
return this.filePosition.HasValue;
}
///
/// 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;
}
}
internal int IVSize { get; set; }
///
/// Gets or sets whether the Content-MD5 header should be calculated for upload.
///
public bool CalculateContentMD5Header
{
get { return this.calculateContentMD5Header; }
set { this.calculateContentMD5Header = value; }
}
}
}