Skip to content

Commit 1f87b13

Browse files
Update Response mapping logic for PutObjectResponse and CompleteMultipartResponse (#4086)
1 parent 2b20531 commit 1f87b13

File tree

6 files changed

+166
-5
lines changed

6 files changed

+166
-5
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+
"Update Response mapping logic for PutObjectResponse and CompleteMultipartResponse"
8+
]
9+
}
10+
]
11+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ internal static TransferUtilityUploadResponse MapPutObjectResponse(PutObjectResp
6161
response.ServerSideEncryptionKeyManagementServiceKeyId = source.ServerSideEncryptionKeyManagementServiceKeyId;
6262
response.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;
6363
response.VersionId = source.VersionId;
64+
response.Size = source.Size;
6465

6566
// Copy response metadata
6667
response.ResponseMetadata = source.ResponseMetadata;
@@ -97,6 +98,9 @@ internal static TransferUtilityUploadResponse MapCompleteMultipartUploadResponse
9798
response.ServerSideEncryptionMethod = source.ServerSideEncryptionMethod;
9899
response.ServerSideEncryptionKeyManagementServiceKeyId = source.ServerSideEncryptionKeyManagementServiceKeyId;
99100
response.VersionId = source.VersionId;
101+
response.BucketName = source.BucketName;
102+
response.Key = source.Key;
103+
response.Location = source.Location;
100104

101105
// Copy response metadata
102106
response.ResponseMetadata = source.ResponseMetadata;

sdk/src/Services/S3/Custom/Transfer/TransferUtilityUploadResponse.cs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace Amazon.S3.Transfer
3535
public class TransferUtilityUploadResponse : AmazonWebServiceResponse
3636
{
3737
private bool? _bucketKeyEnabled;
38+
private string _bucketName;
3839
private string _checksumCRC32;
3940
private string _checksumCRC32C;
4041
private string _checksumCRC64NVME;
@@ -43,8 +44,11 @@ public class TransferUtilityUploadResponse : AmazonWebServiceResponse
4344
private ChecksumType _checksumType;
4445
private string _etag;
4546
private Expiration _expiration;
47+
private string _key;
48+
private string _location;
4649
private RequestCharged _requestCharged;
4750
private ServerSideEncryptionCustomerMethod _serverSideEncryptionCustomerMethod;
51+
private long? _size;
4852
private string _sseCustomerKeyMD5;
4953
private string _sseKmsEncryptionContext;
5054
private string _sseKmsKeyId;
@@ -73,6 +77,110 @@ internal bool IsSetBucketKeyEnabled()
7377
return this._bucketKeyEnabled.HasValue;
7478
}
7579

80+
/// <summary>
81+
/// Gets and sets the property BucketName.
82+
/// <para>
83+
/// The name of the bucket that contains the newly created object. Does not return the
84+
/// access point ARN or access point alias if used.
85+
/// </para>
86+
///
87+
/// <para>
88+
/// When using this action with an access point, you must direct requests to the access
89+
/// point hostname. The access point hostname takes the form <i>AccessPointName</i>-<i>AccountId</i>.s3-accesspoint.<i>Region</i>.amazonaws.com.
90+
/// When using this action with an access point through the Amazon Web Services SDKs,
91+
/// you provide the access point ARN in place of the bucket name. For more information
92+
/// about access point ARNs, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-access-points.html">Using
93+
/// access points</a> in the <i>Amazon S3 User Guide</i>.
94+
/// </para>
95+
///
96+
/// <para>
97+
/// When you use this action with Amazon S3 on Outposts, you must direct requests to the
98+
/// S3 on Outposts hostname. The S3 on Outposts hostname takes the form <code> <i>AccessPointName</i>-<i>AccountId</i>.<i>outpostID</i>.s3-outposts.<i>Region</i>.amazonaws.com</code>.
99+
/// When you use this action with S3 on Outposts through the Amazon Web Services SDKs,
100+
/// you provide the Outposts access point ARN in place of the bucket name. For more information
101+
/// about S3 on Outposts ARNs, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/S3onOutposts.html">What
102+
/// is S3 on Outposts?</a> in the <i>Amazon S3 User Guide</i>.
103+
/// </para>
104+
/// </summary>
105+
public string BucketName
106+
{
107+
get { return this._bucketName; }
108+
set { this._bucketName = value; }
109+
}
110+
111+
/// <summary>
112+
/// Checks if BucketName property is set.
113+
/// </summary>
114+
/// <returns>true if BucketName property is set.</returns>
115+
internal bool IsSetBucketName()
116+
{
117+
return !string.IsNullOrEmpty(this._bucketName);
118+
}
119+
120+
/// <summary>
121+
/// Gets and sets the property Key.
122+
/// <para>
123+
/// The object key of the newly created object.
124+
/// </para>
125+
/// </summary>
126+
public string Key
127+
{
128+
get { return this._key; }
129+
set { this._key = value; }
130+
}
131+
132+
/// <summary>
133+
/// Checks if Key property is set.
134+
/// </summary>
135+
/// <returns>true if Key property is set.</returns>
136+
internal bool IsSetKey()
137+
{
138+
return !string.IsNullOrEmpty(this._key);
139+
}
140+
141+
/// <summary>
142+
/// Gets and sets the property Location.
143+
/// <para>
144+
/// The URI that identifies the newly created object.
145+
/// </para>
146+
/// </summary>
147+
public string Location
148+
{
149+
get { return this._location; }
150+
set { this._location = value; }
151+
}
152+
153+
/// <summary>
154+
/// Checks if Location property is set.
155+
/// </summary>
156+
/// <returns>true if Location property is set.</returns>
157+
internal bool IsSetLocation()
158+
{
159+
return !string.IsNullOrEmpty(this._location);
160+
}
161+
162+
/// <summary>
163+
/// Gets and sets the property Size.
164+
/// <para>
165+
/// The size of the object in bytes. This will only be present if you append to an object.
166+
/// </para>
167+
/// <note><para>This functionality is only supported for objects in the S3 Express One Zone storage class in directory buckets.</para></note>
168+
/// </summary>
169+
public long? Size
170+
{
171+
get { return this._size; }
172+
set { this._size = value; }
173+
}
174+
175+
/// <summary>
176+
/// Checks if Size property is set.
177+
/// </summary>
178+
/// <returns>true if Size property is set.</returns>
179+
internal bool IsSetSize()
180+
{
181+
return this._size.HasValue;
182+
}
183+
76184
/// <summary>
77185
/// Gets and sets the property ChecksumCRC32.
78186
/// <para>

sdk/test/Services/S3/UnitTests/Custom/EmbeddedResource/mapping.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
},
4444
"UploadResponse": {
4545
"PutObjectResponse": [
46+
"Bucket",
4647
"BucketKeyEnabled",
4748
"ChecksumCRC32",
4849
"ChecksumCRC32C",
@@ -52,12 +53,15 @@
5253
"ChecksumType",
5354
"ETag",
5455
"Expiration",
56+
"Key",
57+
"Location",
5558
"RequestCharged",
5659
"SSECustomerAlgorithm",
5760
"SSECustomerKeyMD5",
5861
"SSEKMSEncryptionContext",
5962
"SSEKMSKeyId",
6063
"ServerSideEncryption",
64+
"Size",
6165
"VersionId"
6266
]
6367
},
@@ -129,19 +133,43 @@
129133
"Conversion": {
130134
"UploadRequest": {
131135
"PutObjectRequest": [
136+
"ACL",
132137
"Bucket",
138+
"BucketKeyEnabled",
139+
"CacheControl",
133140
"ChecksumAlgorithm",
134141
"ChecksumCRC32",
135142
"ChecksumCRC32C",
136143
"ChecksumCRC64NVME",
137144
"ChecksumSHA1",
138145
"ChecksumSHA256",
146+
"ContentDisposition",
147+
"ContentEncoding",
148+
"ContentLanguage",
149+
"ContentType",
139150
"ExpectedBucketOwner",
151+
"Expires",
152+
"GrantFullControl",
153+
"GrantRead",
154+
"GrantReadACP",
155+
"GrantWriteACP",
156+
"IfMatch",
157+
"IfNoneMatch",
140158
"Key",
159+
"Metadata",
160+
"ObjectLockLegalHoldStatus",
161+
"ObjectLockMode",
162+
"ObjectLockRetainUntilDate",
141163
"RequestPayer",
142164
"SSECustomerAlgorithm",
143165
"SSECustomerKey",
144-
"SSECustomerKeyMD5"
166+
"SSECustomerKeyMD5",
167+
"SSEKMSEncryptionContext",
168+
"SSEKMSKeyId",
169+
"ServerSideEncryption",
170+
"StorageClass",
171+
"Tagging",
172+
"WebsiteRedirectLocation"
145173
],
146174
"CreateMultipartRequest": [
147175
"ACL",
@@ -210,6 +238,7 @@
210238
},
211239
"CompleteMultipartResponse": {
212240
"UploadResponse": [
241+
"Bucket",
213242
"BucketKeyEnabled",
214243
"ChecksumCRC32",
215244
"ChecksumCRC32C",
@@ -219,6 +248,8 @@
219248
"ChecksumType",
220249
"ETag",
221250
"Expiration",
251+
"Key",
252+
"Location",
222253
"RequestCharged",
223254
"SSEKMSKeyId",
224255
"ServerSideEncryption",
@@ -242,6 +273,7 @@
242273
"SSEKMSEncryptionContext",
243274
"SSEKMSKeyId",
244275
"ServerSideEncryption",
276+
"Size",
245277
"VersionId"
246278
]
247279
},

sdk/test/Services/S3/UnitTests/Custom/EmbeddedResource/property-aliases.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"SSEKMSKeyId": "ServerSideEncryptionKeyManagementServiceKeyId"
99
},
1010
"TransferUtilityUploadResponse": {
11+
"Bucket" : "BucketName",
1112
"ServerSideEncryption": "ServerSideEncryptionMethod",
1213
"SSECustomerAlgorithm": "ServerSideEncryptionCustomerMethod",
1314
"SSECustomerKeyMD5": "ServerSideEncryptionCustomerProvidedKeyMD5",
@@ -114,6 +115,7 @@
114115
"Bucket": "BucketName"
115116
},
116117
"CompleteMultipartUploadResponse": {
118+
"Bucket" : "BucketName",
117119
"ServerSideEncryption": "ServerSideEncryptionMethod",
118120
"SSEKMSKeyId": "ServerSideEncryptionKeyManagementServiceKeyId"
119121
},

sdk/test/Services/S3/UnitTests/Custom/ResponseMapperTests.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void MapUploadRequest_PutObjectRequest_AllMappedProperties_WorkCorrectly(
165165
var simpleUploadCommand = new SimpleUploadCommand(null, null, sourceRequest);
166166
return simpleUploadCommand.ConstructRequest();
167167
},
168-
usesHeadersCollection: false,
168+
usesHeadersCollection: true,
169169
(sourceRequest) =>
170170
{
171171
sourceRequest.InputStream = new MemoryStream(1024);
@@ -742,10 +742,14 @@ private static object GenerateTestValue(Type propertyType, string propertyName)
742742
};
743743
}
744744

745-
// Integer types
746-
if (propertyType == typeof(int) || propertyType == typeof(long))
745+
if (propertyType == typeof(int))
746+
{
747+
return 1024;
748+
}
749+
750+
if (propertyType == typeof(long))
747751
{
748-
return 1024;
752+
return 1024L; // Return long literal
749753
}
750754

751755
if (propertyType == typeof(List<S3Grant>))

0 commit comments

Comments
 (0)