1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/s3/model/CreateMultipartUploadRequest.h>
7 #include <aws/core/utils/xml/XmlSerializer.h>
8 #include <aws/core/utils/memory/stl/AWSStringStream.h>
9 #include <aws/core/http/URI.h>
10 #include <aws/core/utils/memory/stl/AWSStringStream.h>
11
12 #include <utility>
13
14 using namespace Aws::S3::Model;
15 using namespace Aws::Utils::Xml;
16 using namespace Aws::Utils;
17 using namespace Aws::Http;
18
CreateMultipartUploadRequest()19 CreateMultipartUploadRequest::CreateMultipartUploadRequest() :
20 m_aCL(ObjectCannedACL::NOT_SET),
21 m_aCLHasBeenSet(false),
22 m_bucketHasBeenSet(false),
23 m_cacheControlHasBeenSet(false),
24 m_contentDispositionHasBeenSet(false),
25 m_contentEncodingHasBeenSet(false),
26 m_contentLanguageHasBeenSet(false),
27 m_contentTypeHasBeenSet(false),
28 m_expiresHasBeenSet(false),
29 m_grantFullControlHasBeenSet(false),
30 m_grantReadHasBeenSet(false),
31 m_grantReadACPHasBeenSet(false),
32 m_grantWriteACPHasBeenSet(false),
33 m_keyHasBeenSet(false),
34 m_metadataHasBeenSet(false),
35 m_serverSideEncryption(ServerSideEncryption::NOT_SET),
36 m_serverSideEncryptionHasBeenSet(false),
37 m_storageClass(StorageClass::NOT_SET),
38 m_storageClassHasBeenSet(false),
39 m_websiteRedirectLocationHasBeenSet(false),
40 m_sSECustomerAlgorithmHasBeenSet(false),
41 m_sSECustomerKeyHasBeenSet(false),
42 m_sSECustomerKeyMD5HasBeenSet(false),
43 m_sSEKMSKeyIdHasBeenSet(false),
44 m_sSEKMSEncryptionContextHasBeenSet(false),
45 m_bucketKeyEnabled(false),
46 m_bucketKeyEnabledHasBeenSet(false),
47 m_requestPayer(RequestPayer::NOT_SET),
48 m_requestPayerHasBeenSet(false),
49 m_taggingHasBeenSet(false),
50 m_objectLockMode(ObjectLockMode::NOT_SET),
51 m_objectLockModeHasBeenSet(false),
52 m_objectLockRetainUntilDateHasBeenSet(false),
53 m_objectLockLegalHoldStatus(ObjectLockLegalHoldStatus::NOT_SET),
54 m_objectLockLegalHoldStatusHasBeenSet(false),
55 m_expectedBucketOwnerHasBeenSet(false),
56 m_customizedAccessLogTagHasBeenSet(false)
57 {
58 }
59
SerializePayload() const60 Aws::String CreateMultipartUploadRequest::SerializePayload() const
61 {
62 return {};
63 }
64
AddQueryStringParameters(URI & uri) const65 void CreateMultipartUploadRequest::AddQueryStringParameters(URI& uri) const
66 {
67 Aws::StringStream ss;
68 if(!m_customizedAccessLogTag.empty())
69 {
70 // only accept customized LogTag which starts with "x-"
71 Aws::Map<Aws::String, Aws::String> collectedLogTags;
72 for(const auto& entry: m_customizedAccessLogTag)
73 {
74 if (!entry.first.empty() && !entry.second.empty() && entry.first.substr(0, 2) == "x-")
75 {
76 collectedLogTags.emplace(entry.first, entry.second);
77 }
78 }
79
80 if (!collectedLogTags.empty())
81 {
82 uri.AddQueryStringParameter(collectedLogTags);
83 }
84 }
85 }
86
GetRequestSpecificHeaders() const87 Aws::Http::HeaderValueCollection CreateMultipartUploadRequest::GetRequestSpecificHeaders() const
88 {
89 Aws::Http::HeaderValueCollection headers;
90 Aws::StringStream ss;
91 if(m_aCLHasBeenSet)
92 {
93 headers.emplace("x-amz-acl", ObjectCannedACLMapper::GetNameForObjectCannedACL(m_aCL));
94 }
95
96 if(m_cacheControlHasBeenSet)
97 {
98 ss << m_cacheControl;
99 headers.emplace("cache-control", ss.str());
100 ss.str("");
101 }
102
103 if(m_contentDispositionHasBeenSet)
104 {
105 ss << m_contentDisposition;
106 headers.emplace("content-disposition", ss.str());
107 ss.str("");
108 }
109
110 if(m_contentEncodingHasBeenSet)
111 {
112 ss << m_contentEncoding;
113 headers.emplace("content-encoding", ss.str());
114 ss.str("");
115 }
116
117 if(m_contentLanguageHasBeenSet)
118 {
119 ss << m_contentLanguage;
120 headers.emplace("content-language", ss.str());
121 ss.str("");
122 }
123
124 if(m_contentTypeHasBeenSet)
125 {
126 ss << m_contentType;
127 headers.emplace("content-type", ss.str());
128 ss.str("");
129 }
130
131 if(m_expiresHasBeenSet)
132 {
133 headers.emplace("expires", m_expires.ToGmtString(DateFormat::RFC822));
134 }
135
136 if(m_grantFullControlHasBeenSet)
137 {
138 ss << m_grantFullControl;
139 headers.emplace("x-amz-grant-full-control", ss.str());
140 ss.str("");
141 }
142
143 if(m_grantReadHasBeenSet)
144 {
145 ss << m_grantRead;
146 headers.emplace("x-amz-grant-read", ss.str());
147 ss.str("");
148 }
149
150 if(m_grantReadACPHasBeenSet)
151 {
152 ss << m_grantReadACP;
153 headers.emplace("x-amz-grant-read-acp", ss.str());
154 ss.str("");
155 }
156
157 if(m_grantWriteACPHasBeenSet)
158 {
159 ss << m_grantWriteACP;
160 headers.emplace("x-amz-grant-write-acp", ss.str());
161 ss.str("");
162 }
163
164 if(m_metadataHasBeenSet)
165 {
166 for(const auto& item : m_metadata)
167 {
168 ss << "x-amz-meta-" << item.first;
169 headers.emplace(ss.str(), item.second);
170 ss.str("");
171 }
172 }
173
174 if(m_serverSideEncryptionHasBeenSet)
175 {
176 headers.emplace("x-amz-server-side-encryption", ServerSideEncryptionMapper::GetNameForServerSideEncryption(m_serverSideEncryption));
177 }
178
179 if(m_storageClassHasBeenSet)
180 {
181 headers.emplace("x-amz-storage-class", StorageClassMapper::GetNameForStorageClass(m_storageClass));
182 }
183
184 if(m_websiteRedirectLocationHasBeenSet)
185 {
186 ss << m_websiteRedirectLocation;
187 headers.emplace("x-amz-website-redirect-location", ss.str());
188 ss.str("");
189 }
190
191 if(m_sSECustomerAlgorithmHasBeenSet)
192 {
193 ss << m_sSECustomerAlgorithm;
194 headers.emplace("x-amz-server-side-encryption-customer-algorithm", ss.str());
195 ss.str("");
196 }
197
198 if(m_sSECustomerKeyHasBeenSet)
199 {
200 ss << m_sSECustomerKey;
201 headers.emplace("x-amz-server-side-encryption-customer-key", ss.str());
202 ss.str("");
203 }
204
205 if(m_sSECustomerKeyMD5HasBeenSet)
206 {
207 ss << m_sSECustomerKeyMD5;
208 headers.emplace("x-amz-server-side-encryption-customer-key-md5", ss.str());
209 ss.str("");
210 }
211
212 if(m_sSEKMSKeyIdHasBeenSet)
213 {
214 ss << m_sSEKMSKeyId;
215 headers.emplace("x-amz-server-side-encryption-aws-kms-key-id", ss.str());
216 ss.str("");
217 }
218
219 if(m_sSEKMSEncryptionContextHasBeenSet)
220 {
221 ss << m_sSEKMSEncryptionContext;
222 headers.emplace("x-amz-server-side-encryption-context", ss.str());
223 ss.str("");
224 }
225
226 if(m_bucketKeyEnabledHasBeenSet)
227 {
228 ss << std::boolalpha << m_bucketKeyEnabled;
229 headers.emplace("x-amz-server-side-encryption-bucket-key-enabled", ss.str());
230 ss.str("");
231 }
232
233 if(m_requestPayerHasBeenSet)
234 {
235 headers.emplace("x-amz-request-payer", RequestPayerMapper::GetNameForRequestPayer(m_requestPayer));
236 }
237
238 if(m_taggingHasBeenSet)
239 {
240 ss << m_tagging;
241 headers.emplace("x-amz-tagging", ss.str());
242 ss.str("");
243 }
244
245 if(m_objectLockModeHasBeenSet)
246 {
247 headers.emplace("x-amz-object-lock-mode", ObjectLockModeMapper::GetNameForObjectLockMode(m_objectLockMode));
248 }
249
250 if(m_objectLockRetainUntilDateHasBeenSet)
251 {
252 headers.emplace("x-amz-object-lock-retain-until-date", m_objectLockRetainUntilDate.ToGmtString(DateFormat::ISO_8601));
253 }
254
255 if(m_objectLockLegalHoldStatusHasBeenSet)
256 {
257 headers.emplace("x-amz-object-lock-legal-hold", ObjectLockLegalHoldStatusMapper::GetNameForObjectLockLegalHoldStatus(m_objectLockLegalHoldStatus));
258 }
259
260 if(m_expectedBucketOwnerHasBeenSet)
261 {
262 ss << m_expectedBucketOwner;
263 headers.emplace("x-amz-expected-bucket-owner", ss.str());
264 ss.str("");
265 }
266
267 return headers;
268 }
269