Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions generator/.DevConfigs/7f23582e-3225-487b-83e7-167cf17cb231.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"services": [
{
"serviceName": "S3",
"type": "patch",
"changeLogMessages": [
"Add GetObjectResponse to TransferUtilityDownloadResponse mapping."
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private static void UnmarshallResult(XmlUnmarshallerContext context,GetObjectRes
response.ContentLanguage = S3Transforms.ToString(responseData.GetHeaderValue("Content-Language"));
if (responseData.IsHeaderPresent("Content-Length"))
response.Headers.ContentLength = long.Parse(responseData.GetHeaderValue("Content-Length"), CultureInfo.InvariantCulture);
response.Headers.ContentLanguage = S3Transforms.ToString(responseData.GetHeaderValue("Content-Language"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds this to the header to make it easy for TransferUtilityDownloadResponse, since we just copy source.header to target.header

if (responseData.IsHeaderPresent("x-amz-object-lock-legal-hold"))
response.ObjectLockLegalHoldStatus = S3Transforms.ToString(responseData.GetHeaderValue("x-amz-object-lock-legal-hold"));
if (responseData.IsHeaderPresent("x-amz-object-lock-mode"))
Expand Down
122 changes: 122 additions & 0 deletions sdk/src/Services/S3/Custom/Transfer/Internal/ResponseMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*
*/

using System.Collections.Generic;
using Amazon.S3.Model;

namespace Amazon.S3.Transfer.Internal
Expand Down Expand Up @@ -160,6 +161,127 @@ internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse

return response;
}

/// <summary>
/// Maps a GetObjectResponse to TransferUtilityDownloadResponse.
/// Uses the field mappings defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse".
/// </summary>
/// <param name="source">The GetObjectResponse to map from</param>
/// <returns>A new TransferUtilityDownloadResponse with mapped fields</returns>
internal static TransferUtilityDownloadResponse MapGetObjectResponse(GetObjectResponse source)
{
if (source == null)
return null;

var response = new TransferUtilityDownloadResponse();

// Map all fields as defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse"
if (source.IsSetAcceptRanges())
response.AcceptRanges = source.AcceptRanges;

if (source.IsSetBucketKeyEnabled())
response.BucketKeyEnabled = source.BucketKeyEnabled.GetValueOrDefault();

if (source.IsSetChecksumCRC32())
response.ChecksumCRC32 = source.ChecksumCRC32;

if (source.IsSetChecksumCRC32C())
response.ChecksumCRC32C = source.ChecksumCRC32C;

if (source.IsSetChecksumCRC64NVME())
response.ChecksumCRC64NVME = source.ChecksumCRC64NVME;

if (source.IsSetChecksumSHA1())
response.ChecksumSHA1 = source.ChecksumSHA1;

if (source.IsSetChecksumSHA256())
response.ChecksumSHA256 = source.ChecksumSHA256;

if (source.IsSetChecksumType())
response.ChecksumType = source.ChecksumType;

response.ContentLength = source.ContentLength;

if (source.IsSetContentRange())
response.ContentRange = source.ContentRange;

response.Headers = source.Headers;

if (source.IsSetDeleteMarker())
response.DeleteMarker = source.DeleteMarker;

if (source.IsSetETag())
response.ETag = source.ETag;

if (source.Expiration != null)
response.Expiration = source.Expiration;

if (source.ExpiresString != null)
response.ExpiresString = source.ExpiresString;

if (source.IsSetLastModified())
response.LastModified = source.LastModified;

if (source.Metadata != null)
response.Metadata = source.Metadata;

if (source.IsSetMissingMeta())
response.MissingMeta = source.MissingMeta;

if (source.IsSetObjectLockLegalHoldStatus())
response.ObjectLockLegalHoldStatus = source.ObjectLockLegalHoldStatus;

if (source.IsSetObjectLockMode())
response.ObjectLockMode = source.ObjectLockMode;

if (source.IsSetObjectLockRetainUntilDate())
response.ObjectLockRetainUntilDate = source.ObjectLockRetainUntilDate;

if (source.IsSetPartsCount())
response.PartsCount = source.PartsCount;

if (source.IsSetReplicationStatus())
response.ReplicationStatus = source.ReplicationStatus;

if (source.IsSetRequestCharged())
response.RequestCharged = source.RequestCharged;

if (source.RestoreExpiration.HasValue)
response.RestoreExpiration = source.RestoreExpiration;

if (source.RestoreInProgress.HasValue)
response.RestoreInProgress = source.RestoreInProgress;

if (source.ServerSideEncryptionCustomerMethod != null)
response.ServerSideEncryptionCustomerMethod = source.ServerSideEncryptionCustomerMethod;

if (source.ServerSideEncryptionCustomerProvidedKeyMD5 != null)
response.ServerSideEncryptionCustomerProvidedKeyMD5 = source.ServerSideEncryptionCustomerProvidedKeyMD5;

if (source.IsSetServerSideEncryptionKeyManagementServiceKeyId())
response.ServerSideEncryptionKeyManagementServiceKeyId = source.ServerSideEncryptionKeyManagementServiceKeyId;

if (source.IsSetServerSideEncryptionMethod())
response.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;

if (source.IsSetStorageClass())
response.StorageClass = source.StorageClass;

response.TagCount = source.TagCount;

if (source.IsSetVersionId())
response.VersionId = source.VersionId;

if (source.IsSetWebsiteRedirectLocation())
response.WebsiteRedirectLocation = source.WebsiteRedirectLocation;

// Copy response metadata
response.ResponseMetadata = source.ResponseMetadata;
response.ContentLength = source.ContentLength;
response.HttpStatusCode = source.HttpStatusCode;

return response;
}

}
}
Loading