1/*
2* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3*
4* Licensed under the Apache License, Version 2.0 (the "License").
5* You may not use this file except in compliance with the License.
6* A copy of the License is located at
7*
8* http://aws.amazon.com/apache2.0
9*
10* or in the "license" file accompanying this file. This file is distributed
11* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12* express or implied. See the License for the specific language governing
13* permissions and limitations under the License.
14*/
15
16#include <aws/s3/model/CreateMultipartUploadRequest.h>
17#include <aws/core/utils/xml/XmlSerializer.h>
18#include <aws/core/utils/memory/stl/AWSStringStream.h>
19#include <aws/core/http/URI.h>
20#include <aws/core/utils/memory/stl/AWSStringStream.h>
21
22#include <utility>
23
24using namespace Aws::S3::Model;
25using namespace Aws::Utils::Xml;
26using namespace Aws::Utils;
27using namespace Aws::Http;
28
29CreateMultipartUploadRequest::CreateMultipartUploadRequest() :
30 m_aCL(ObjectCannedACL::NOT_SET),
31 m_aCLHasBeenSet(false),
32 m_bucketHasBeenSet(false),
33 m_cacheControlHasBeenSet(false),
34 m_contentDispositionHasBeenSet(false),
35 m_contentEncodingHasBeenSet(false),
36 m_contentLanguageHasBeenSet(false),
37 m_contentTypeHasBeenSet(false),
38 m_expiresHasBeenSet(false),
39 m_grantFullControlHasBeenSet(false),
40 m_grantReadHasBeenSet(false),
41 m_grantReadACPHasBeenSet(false),
42 m_grantWriteACPHasBeenSet(false),
43 m_keyHasBeenSet(false),
44 m_metadataHasBeenSet(false),
45 m_serverSideEncryption(ServerSideEncryption::NOT_SET),
46 m_serverSideEncryptionHasBeenSet(false),
47 m_storageClass(StorageClass::NOT_SET),
48 m_storageClassHasBeenSet(false),
49 m_websiteRedirectLocationHasBeenSet(false),
50 m_sSECustomerAlgorithmHasBeenSet(false),
51 m_sSECustomerKeyHasBeenSet(false),
52 m_sSECustomerKeyMD5HasBeenSet(false),
53 m_sSEKMSKeyIdHasBeenSet(false),
54 m_sSEKMSEncryptionContextHasBeenSet(false),
55 m_requestPayer(RequestPayer::NOT_SET),
56 m_requestPayerHasBeenSet(false),
57 m_taggingHasBeenSet(false),
58 m_objectLockMode(ObjectLockMode::NOT_SET),
59 m_objectLockModeHasBeenSet(false),
60 m_objectLockRetainUntilDateHasBeenSet(false),
61 m_objectLockLegalHoldStatus(ObjectLockLegalHoldStatus::NOT_SET),
62 m_objectLockLegalHoldStatusHasBeenSet(false),
63 m_customizedAccessLogTagHasBeenSet(false)
64{
65}
66
67Aws::String CreateMultipartUploadRequest::SerializePayload() const
68{
69 return {};
70}
71
72void CreateMultipartUploadRequest::AddQueryStringParameters(URI& uri) const
73{
74 Aws::StringStream ss;
75 if(!m_customizedAccessLogTag.empty())
76 {
77 // only accept customized LogTag which starts with "x-"
78 Aws::Map<Aws::String, Aws::String> collectedLogTags;
79 for(const auto& entry: m_customizedAccessLogTag)
80 {
81 if (!entry.first.empty() && !entry.second.empty() && entry.first.substr(0, 2) == "x-")
82 {
83 collectedLogTags.emplace(entry.first, entry.second);
84 }
85 }
86
87 if (!collectedLogTags.empty())
88 {
89 uri.AddQueryStringParameter(collectedLogTags);
90 }
91 }
92}
93
94Aws::Http::HeaderValueCollection CreateMultipartUploadRequest::GetRequestSpecificHeaders() const
95{
96 Aws::Http::HeaderValueCollection headers;
97 Aws::StringStream ss;
98 if(m_aCLHasBeenSet)
99 {
100 headers.emplace("x-amz-acl", ObjectCannedACLMapper::GetNameForObjectCannedACL(m_aCL));
101 }
102
103 if(m_cacheControlHasBeenSet)
104 {
105 ss << m_cacheControl;
106 headers.emplace("cache-control", ss.str());
107 ss.str("");
108 }
109
110 if(m_contentDispositionHasBeenSet)
111 {
112 ss << m_contentDisposition;
113 headers.emplace("content-disposition", ss.str());
114 ss.str("");
115 }
116
117 if(m_contentEncodingHasBeenSet)
118 {
119 ss << m_contentEncoding;
120 headers.emplace("content-encoding", ss.str());
121 ss.str("");
122 }
123
124 if(m_contentLanguageHasBeenSet)
125 {
126 ss << m_contentLanguage;
127 headers.emplace("content-language", ss.str());
128 ss.str("");
129 }
130
131 if(m_contentTypeHasBeenSet)
132 {
133 ss << m_contentType;
134 headers.emplace("content-type", ss.str());
135 ss.str("");
136 }
137
138 if(m_expiresHasBeenSet)
139 {
140 headers.emplace("expires", m_expires.ToGmtString(DateFormat::RFC822));
141 }
142
143 if(m_grantFullControlHasBeenSet)
144 {
145 ss << m_grantFullControl;
146 headers.emplace("x-amz-grant-full-control", ss.str());
147 ss.str("");
148 }
149
150 if(m_grantReadHasBeenSet)
151 {
152 ss << m_grantRead;
153 headers.emplace("x-amz-grant-read", ss.str());
154 ss.str("");
155 }
156
157 if(m_grantReadACPHasBeenSet)
158 {
159 ss << m_grantReadACP;
160 headers.emplace("x-amz-grant-read-acp", ss.str());
161 ss.str("");
162 }
163
164 if(m_grantWriteACPHasBeenSet)
165 {
166 ss << m_grantWriteACP;
167 headers.emplace("x-amz-grant-write-acp", ss.str());
168 ss.str("");
169 }
170
171 if(m_metadataHasBeenSet)
172 {
173 for(const auto& item : m_metadata)
174 {
175 ss << "x-amz-meta-" << item.first;
176 headers.emplace(ss.str(), item.second);
177 ss.str("");
178 }
179 }
180
181 if(m_serverSideEncryptionHasBeenSet)
182 {
183 headers.emplace("x-amz-server-side-encryption", ServerSideEncryptionMapper::GetNameForServerSideEncryption(m_serverSideEncryption));
184 }
185
186 if(m_storageClassHasBeenSet)
187 {
188 headers.emplace("x-amz-storage-class", StorageClassMapper::GetNameForStorageClass(m_storageClass));
189 }
190
191 if(m_websiteRedirectLocationHasBeenSet)
192 {
193 ss << m_websiteRedirectLocation;
194 headers.emplace("x-amz-website-redirect-location", ss.str());
195 ss.str("");
196 }
197
198 if(m_sSECustomerAlgorithmHasBeenSet)
199 {
200 ss << m_sSECustomerAlgorithm;
201 headers.emplace("x-amz-server-side-encryption-customer-algorithm", ss.str());
202 ss.str("");
203 }
204
205 if(m_sSECustomerKeyHasBeenSet)
206 {
207 ss << m_sSECustomerKey;
208 headers.emplace("x-amz-server-side-encryption-customer-key", ss.str());
209 ss.str("");
210 }
211
212 if(m_sSECustomerKeyMD5HasBeenSet)
213 {
214 ss << m_sSECustomerKeyMD5;
215 headers.emplace("x-amz-server-side-encryption-customer-key-md5", ss.str());
216 ss.str("");
217 }
218
219 if(m_sSEKMSKeyIdHasBeenSet)
220 {
221 ss << m_sSEKMSKeyId;
222 headers.emplace("x-amz-server-side-encryption-aws-kms-key-id", ss.str());
223 ss.str("");
224 }
225
226 if(m_sSEKMSEncryptionContextHasBeenSet)
227 {
228 ss << m_sSEKMSEncryptionContext;
229 headers.emplace("x-amz-server-side-encryption-context", 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::RFC822));
253 }
254
255 if(m_objectLockLegalHoldStatusHasBeenSet)
256 {
257 headers.emplace("x-amz-object-lock-legal-hold", ObjectLockLegalHoldStatusMapper::GetNameForObjectLockLegalHoldStatus(m_objectLockLegalHoldStatus));
258 }
259
260 return headers;
261}
262