From 7fd9f01ab2096cc7a73d7daadcc933716678d9a0 Mon Sep 17 00:00:00 2001 From: Jason Del Ponte Date: Fri, 29 Sep 2017 12:49:37 -0700 Subject: [PATCH] service/s3: Fix PutObject and UploadPart API to include ContentMD5 field (#1559) Fixes the SDK's S3 PutObject and UploadPart API code generation to correctly render the ContentMD5 field into the associated input types for these two API operations. Fix #1553 --- private/model/api/customization_passes.go | 14 +++++++++++--- service/s3/api.go | 18 ++++++++++++++++++ service/s3/s3manager/upload.go | 3 +++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/private/model/api/customization_passes.go b/private/model/api/customization_passes.go index 7b17e950092..a17e22b6aa3 100644 --- a/private/model/api/customization_passes.go +++ b/private/model/api/customization_passes.go @@ -53,12 +53,20 @@ func (a *API) customizationPasses() { func s3Customizations(a *API) { var strExpires *Shape + var keepContentMD5Ref = map[string]struct{}{ + "PutObjectInput": struct{}{}, + "UploadPartInput": struct{}{}, + } + for name, s := range a.Shapes { - // Remove ContentMD5 members - if _, ok := s.MemberRefs["ContentMD5"]; ok { - delete(s.MemberRefs, "ContentMD5") + // Remove ContentMD5 members unless specified otherwise. + if _, keep := keepContentMD5Ref[name]; !keep { + if _, have := s.MemberRefs["ContentMD5"]; have { + delete(s.MemberRefs, "ContentMD5") + } } + // Generate getter methods for API operation fields used by customizations. for _, refName := range []string{"Bucket", "SSECustomerKey", "CopySourceSSECustomerKey"} { if ref, ok := s.MemberRefs[refName]; ok { ref.GenerateGetter = true diff --git a/service/s3/api.go b/service/s3/api.go index e65ef266f76..1d4fa383548 100644 --- a/service/s3/api.go +++ b/service/s3/api.go @@ -17085,6 +17085,9 @@ type PutObjectInput struct { // body cannot be determined automatically. ContentLength *int64 `location:"header" locationName:"Content-Length" type:"long"` + // The base64-encoded 128-bit MD5 digest of the part data. + ContentMD5 *string `location:"header" locationName:"Content-MD5" type:"string"` + // A standard MIME type describing the format of the object data. ContentType *string `location:"header" locationName:"Content-Type" type:"string"` @@ -17238,6 +17241,12 @@ func (s *PutObjectInput) SetContentLength(v int64) *PutObjectInput { return s } +// SetContentMD5 sets the ContentMD5 field's value. +func (s *PutObjectInput) SetContentMD5(v string) *PutObjectInput { + s.ContentMD5 = &v + return s +} + // SetContentType sets the ContentType field's value. func (s *PutObjectInput) SetContentType(v string) *PutObjectInput { s.ContentType = &v @@ -19079,6 +19088,9 @@ type UploadPartInput struct { // body cannot be determined automatically. ContentLength *int64 `location:"header" locationName:"Content-Length" type:"long"` + // The base64-encoded 128-bit MD5 digest of the part data. + ContentMD5 *string `location:"header" locationName:"Content-MD5" type:"string"` + // Object key for which the multipart upload was initiated. // // Key is a required field @@ -19178,6 +19190,12 @@ func (s *UploadPartInput) SetContentLength(v int64) *UploadPartInput { return s } +// SetContentMD5 sets the ContentMD5 field's value. +func (s *UploadPartInput) SetContentMD5(v string) *UploadPartInput { + s.ContentMD5 = &v + return s +} + // SetKey sets the Key field's value. func (s *UploadPartInput) SetKey(v string) *UploadPartInput { s.Key = &v diff --git a/service/s3/s3manager/upload.go b/service/s3/s3manager/upload.go index 699afb957e1..a4079b83ece 100644 --- a/service/s3/s3manager/upload.go +++ b/service/s3/s3manager/upload.go @@ -117,6 +117,9 @@ type UploadInput struct { // The language the content is in. ContentLanguage *string `location:"header" locationName:"Content-Language" type:"string"` + // The base64-encoded 128-bit MD5 digest of the part data. + ContentMD5 *string `location:"header" locationName:"Content-MD5" type:"string"` + // A standard MIME type describing the format of the object data. ContentType *string `location:"header" locationName:"Content-Type" type:"string"`