Skip to content

Commit a47780d

Browse files
committed
Add DownloadResponse mapping
stack-info: PR: #4063, branch: GarrettBeatty/stacked/5
1 parent eb21a74 commit a47780d

File tree

6 files changed

+791
-4
lines changed

6 files changed

+791
-4
lines changed

sdk/src/Services/S3/Custom/Model/GetObjectResponse.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public partial class GetObjectResponse : StreamResponse
4949
private string websiteRedirectLocation;
5050
private ServerSideEncryptionMethod serverSideEncryption;
5151
private ServerSideEncryptionCustomerMethod serverSideEncryptionCustomerMethod;
52+
private string serverSideEncryptionCustomerProvidedKeyMD5;
5253
private string serverSideEncryptionKeyManagementServiceKeyId;
5354
private HeadersCollection headersCollection = new HeadersCollection();
5455
private MetadataCollection metadataCollection = new MetadataCollection();
@@ -67,6 +68,7 @@ public partial class GetObjectResponse : StreamResponse
6768
private string _checksumSHA1;
6869
private string _checksumSHA256;
6970
private ChecksumType _checksumType;
71+
private string _contentLanguage;
7072

7173
/// <summary>
7274
/// The date and time at which the object is no longer cacheable.
@@ -164,6 +166,24 @@ internal bool IsSetContentRange()
164166
return this.contentRange != null;
165167
}
166168

169+
/// <summary>
170+
/// Gets and sets the property ContentLanguage.
171+
/// <para>
172+
/// The language the content is in.
173+
/// </para>
174+
/// </summary>
175+
public string ContentLanguage
176+
{
177+
get { return this._contentLanguage; }
178+
set { this._contentLanguage = value; }
179+
}
180+
181+
// Check to see if ContentLanguage property is set
182+
internal bool IsSetContentLanguage()
183+
{
184+
return this._contentLanguage != null;
185+
}
186+
167187
/// <summary>
168188
/// Gets and sets the property Expiration.
169189
/// <para>
@@ -539,6 +559,21 @@ public ServerSideEncryptionCustomerMethod ServerSideEncryptionCustomerMethod
539559
set { this.serverSideEncryptionCustomerMethod = value; }
540560
}
541561

562+
/// <summary>
563+
/// The MD5 of the customer encryption key specified in the ServerSideEncryptionCustomerProvidedKey property. The MD5 is
564+
/// base 64 encoded. This field is optional, the SDK will calculate the MD5 if this is not set.
565+
/// <note>
566+
/// <para>
567+
/// This functionality is not supported for directory buckets.
568+
/// </para>
569+
/// </note>
570+
/// </summary>
571+
public string ServerSideEncryptionCustomerProvidedKeyMD5
572+
{
573+
get { return this.serverSideEncryptionCustomerProvidedKeyMD5; }
574+
set { this.serverSideEncryptionCustomerProvidedKeyMD5 = value; }
575+
}
576+
542577
/// <summary>
543578
/// If present, indicates that the requester was successfully charged for the request.
544579
/// </summary>
@@ -1009,4 +1044,3 @@ internal WriteObjectProgressArgs(string bucketName, string key, string filePath,
10091044
public bool IsCompleted { get; private set; }
10101045
}
10111046
}
1012-

sdk/src/Services/S3/Custom/Model/HeadersCollection.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ internal bool IsSetContentType()
152152
return !string.IsNullOrEmpty(this.ContentType);
153153
}
154154

155+
/// <summary>
156+
/// <para>
157+
/// The language the content is in.
158+
/// </para>
159+
/// </summary>
160+
public string ContentLanguage
161+
{
162+
get { return this["Content-Language"]; }
163+
set { this["Content-Language"] = value; }
164+
}
165+
155166
/// <summary>
156167
/// <para>
157168
/// The date and time at which the object is no longer cacheable. For more information,

sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/GetObjectResponseUnmarshaller.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ private static void UnmarshallResult(XmlUnmarshallerContext context,GetObjectRes
8585
response.Headers.ContentDisposition = S3Transforms.ToString(responseData.GetHeaderValue("Content-Disposition"));
8686
if (responseData.IsHeaderPresent("Content-Encoding"))
8787
response.Headers.ContentEncoding = S3Transforms.ToString(responseData.GetHeaderValue("Content-Encoding"));
88+
if (responseData.IsHeaderPresent("Content-Language"))
89+
{
90+
response.ContentLanguage = S3Transforms.ToString(responseData.GetHeaderValue("Content-Language"));
91+
response.Headers.ContentLanguage = S3Transforms.ToString(responseData.GetHeaderValue("Content-Language"));
92+
}
8893
if (responseData.IsHeaderPresent("Content-Length"))
8994
response.Headers.ContentLength = long.Parse(responseData.GetHeaderValue("Content-Length"), CultureInfo.InvariantCulture);
9095
if (responseData.IsHeaderPresent("x-amz-object-lock-legal-hold"))

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)