Skip to content

Commit 0e777fb

Browse files
committed
Add DownloadResponse mapping
1 parent a75c7d4 commit 0e777fb

File tree

5 files changed

+528
-15
lines changed

5 files changed

+528
-15
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"services": [
3+
{
4+
"serviceName": "S3",
5+
"type": "patch",
6+
"changeLogMessages": [
7+
"Add GetObjectResponse to TransferUtilityDownloadResponse mapping."
8+
]
9+
}
10+
]
11+
}

sdk/src/Services/S3/Custom/Transfer/Internal/ResponseMapper.cs

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*
2121
*/
2222

23+
using System.Collections.Generic;
2324
using Amazon.S3.Model;
2425

2526
namespace Amazon.S3.Transfer.Internal
@@ -160,6 +161,127 @@ internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse
160161

161162
return response;
162163
}
164+
165+
/// <summary>
166+
/// Maps a GetObjectResponse to TransferUtilityDownloadResponse.
167+
/// Uses the field mappings defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse".
168+
/// </summary>
169+
/// <param name="source">The GetObjectResponse to map from</param>
170+
/// <returns>A new TransferUtilityDownloadResponse with mapped fields</returns>
171+
internal static TransferUtilityDownloadResponse MapGetObjectResponse(GetObjectResponse source)
172+
{
173+
if (source == null)
174+
return null;
175+
176+
var response = new TransferUtilityDownloadResponse();
177+
178+
// Map all fields as defined in mapping.json "Conversion" -> "GetObjectResponse" -> "DownloadResponse"
179+
if (source.IsSetAcceptRanges())
180+
response.AcceptRanges = source.AcceptRanges;
181+
182+
if (source.IsSetBucketKeyEnabled())
183+
response.BucketKeyEnabled = source.BucketKeyEnabled.GetValueOrDefault();
184+
185+
if (source.IsSetChecksumCRC32())
186+
response.ChecksumCRC32 = source.ChecksumCRC32;
187+
188+
if (source.IsSetChecksumCRC32C())
189+
response.ChecksumCRC32C = source.ChecksumCRC32C;
190+
191+
if (source.IsSetChecksumCRC64NVME())
192+
response.ChecksumCRC64NVME = source.ChecksumCRC64NVME;
193+
194+
if (source.IsSetChecksumSHA1())
195+
response.ChecksumSHA1 = source.ChecksumSHA1;
196+
197+
if (source.IsSetChecksumSHA256())
198+
response.ChecksumSHA256 = source.ChecksumSHA256;
199+
200+
if (source.IsSetChecksumType())
201+
response.ChecksumType = source.ChecksumType;
202+
203+
response.ContentLength = source.ContentLength;
204+
205+
if (source.IsSetContentRange())
206+
response.ContentRange = source.ContentRange;
207+
208+
response.Headers = source.Headers;
209+
210+
if (source.IsSetDeleteMarker())
211+
response.DeleteMarker = source.DeleteMarker;
212+
213+
if (source.IsSetETag())
214+
response.ETag = source.ETag;
215+
216+
if (source.Expiration != null)
217+
response.Expiration = source.Expiration;
218+
219+
if (source.ExpiresString != null)
220+
response.ExpiresString = source.ExpiresString;
221+
222+
if (source.IsSetLastModified())
223+
response.LastModified = source.LastModified;
224+
225+
if (source.Metadata != null)
226+
response.Metadata = source.Metadata;
227+
228+
if (source.IsSetMissingMeta())
229+
response.MissingMeta = source.MissingMeta;
230+
231+
if (source.IsSetObjectLockLegalHoldStatus())
232+
response.ObjectLockLegalHoldStatus = source.ObjectLockLegalHoldStatus;
233+
234+
if (source.IsSetObjectLockMode())
235+
response.ObjectLockMode = source.ObjectLockMode;
236+
237+
if (source.IsSetObjectLockRetainUntilDate())
238+
response.ObjectLockRetainUntilDate = source.ObjectLockRetainUntilDate;
239+
240+
if (source.IsSetPartsCount())
241+
response.PartsCount = source.PartsCount;
242+
243+
if (source.IsSetReplicationStatus())
244+
response.ReplicationStatus = source.ReplicationStatus;
245+
246+
if (source.IsSetRequestCharged())
247+
response.RequestCharged = source.RequestCharged;
248+
249+
if (source.RestoreExpiration.HasValue)
250+
response.RestoreExpiration = source.RestoreExpiration;
251+
252+
if (source.RestoreInProgress.HasValue)
253+
response.RestoreInProgress = source.RestoreInProgress;
254+
255+
if (source.ServerSideEncryptionCustomerMethod != null)
256+
response.ServerSideEncryptionCustomerMethod = source.ServerSideEncryptionCustomerMethod;
257+
258+
if (source.ServerSideEncryptionCustomerProvidedKeyMD5 != null)
259+
response.ServerSideEncryptionCustomerProvidedKeyMD5 = source.ServerSideEncryptionCustomerProvidedKeyMD5;
260+
261+
if (source.IsSetServerSideEncryptionKeyManagementServiceKeyId())
262+
response.ServerSideEncryptionKeyManagementServiceKeyId = source.ServerSideEncryptionKeyManagementServiceKeyId;
263+
264+
if (source.IsSetServerSideEncryptionMethod())
265+
response.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;
266+
267+
if (source.IsSetStorageClass())
268+
response.StorageClass = source.StorageClass;
269+
270+
response.TagCount = source.TagCount;
271+
272+
if (source.IsSetVersionId())
273+
response.VersionId = source.VersionId;
274+
275+
if (source.IsSetWebsiteRedirectLocation())
276+
response.WebsiteRedirectLocation = source.WebsiteRedirectLocation;
277+
278+
// Copy response metadata
279+
response.ResponseMetadata = source.ResponseMetadata;
280+
response.ContentLength = source.ContentLength;
281+
response.HttpStatusCode = source.HttpStatusCode;
282+
283+
return response;
284+
}
163285

164286
}
165287
}

0 commit comments

Comments
 (0)