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/UploadPartCopyRequest.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 | |
24 | using namespace Aws::S3::Model; |
25 | using namespace Aws::Utils::Xml; |
26 | using namespace Aws::Utils; |
27 | using namespace Aws::Http; |
28 | |
29 | UploadPartCopyRequest::UploadPartCopyRequest() : |
30 | m_bucketHasBeenSet(false), |
31 | m_copySourceHasBeenSet(false), |
32 | m_copySourceIfMatchHasBeenSet(false), |
33 | m_copySourceIfModifiedSinceHasBeenSet(false), |
34 | m_copySourceIfNoneMatchHasBeenSet(false), |
35 | m_copySourceIfUnmodifiedSinceHasBeenSet(false), |
36 | m_copySourceRangeHasBeenSet(false), |
37 | m_keyHasBeenSet(false), |
38 | m_partNumber(0), |
39 | m_partNumberHasBeenSet(false), |
40 | m_uploadIdHasBeenSet(false), |
41 | m_sSECustomerAlgorithmHasBeenSet(false), |
42 | m_sSECustomerKeyHasBeenSet(false), |
43 | m_sSECustomerKeyMD5HasBeenSet(false), |
44 | m_copySourceSSECustomerAlgorithmHasBeenSet(false), |
45 | m_copySourceSSECustomerKeyHasBeenSet(false), |
46 | m_copySourceSSECustomerKeyMD5HasBeenSet(false), |
47 | m_requestPayer(RequestPayer::NOT_SET), |
48 | m_requestPayerHasBeenSet(false), |
49 | m_customizedAccessLogTagHasBeenSet(false) |
50 | { |
51 | } |
52 | |
53 | Aws::String UploadPartCopyRequest::SerializePayload() const |
54 | { |
55 | return {}; |
56 | } |
57 | |
58 | void UploadPartCopyRequest::AddQueryStringParameters(URI& uri) const |
59 | { |
60 | Aws::StringStream ss; |
61 | if(m_partNumberHasBeenSet) |
62 | { |
63 | ss << m_partNumber; |
64 | uri.AddQueryStringParameter("partNumber" , ss.str()); |
65 | ss.str("" ); |
66 | } |
67 | |
68 | if(m_uploadIdHasBeenSet) |
69 | { |
70 | ss << m_uploadId; |
71 | uri.AddQueryStringParameter("uploadId" , ss.str()); |
72 | ss.str("" ); |
73 | } |
74 | |
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 | |
94 | Aws::Http::HeaderValueCollection UploadPartCopyRequest::() const |
95 | { |
96 | Aws::Http::HeaderValueCollection ; |
97 | Aws::StringStream ss; |
98 | if(m_copySourceHasBeenSet) |
99 | { |
100 | ss << m_copySource; |
101 | headers.emplace("x-amz-copy-source" , URI::URLEncodePath(ss.str())); |
102 | ss.str("" ); |
103 | } |
104 | |
105 | if(m_copySourceIfMatchHasBeenSet) |
106 | { |
107 | ss << m_copySourceIfMatch; |
108 | headers.emplace("x-amz-copy-source-if-match" , ss.str()); |
109 | ss.str("" ); |
110 | } |
111 | |
112 | if(m_copySourceIfModifiedSinceHasBeenSet) |
113 | { |
114 | headers.emplace("x-amz-copy-source-if-modified-since" , m_copySourceIfModifiedSince.ToGmtString(DateFormat::RFC822)); |
115 | } |
116 | |
117 | if(m_copySourceIfNoneMatchHasBeenSet) |
118 | { |
119 | ss << m_copySourceIfNoneMatch; |
120 | headers.emplace("x-amz-copy-source-if-none-match" , ss.str()); |
121 | ss.str("" ); |
122 | } |
123 | |
124 | if(m_copySourceIfUnmodifiedSinceHasBeenSet) |
125 | { |
126 | headers.emplace("x-amz-copy-source-if-unmodified-since" , m_copySourceIfUnmodifiedSince.ToGmtString(DateFormat::RFC822)); |
127 | } |
128 | |
129 | if(m_copySourceRangeHasBeenSet) |
130 | { |
131 | ss << m_copySourceRange; |
132 | headers.emplace("x-amz-copy-source-range" , ss.str()); |
133 | ss.str("" ); |
134 | } |
135 | |
136 | if(m_sSECustomerAlgorithmHasBeenSet) |
137 | { |
138 | ss << m_sSECustomerAlgorithm; |
139 | headers.emplace("x-amz-server-side-encryption-customer-algorithm" , ss.str()); |
140 | ss.str("" ); |
141 | } |
142 | |
143 | if(m_sSECustomerKeyHasBeenSet) |
144 | { |
145 | ss << m_sSECustomerKey; |
146 | headers.emplace("x-amz-server-side-encryption-customer-key" , ss.str()); |
147 | ss.str("" ); |
148 | } |
149 | |
150 | if(m_sSECustomerKeyMD5HasBeenSet) |
151 | { |
152 | ss << m_sSECustomerKeyMD5; |
153 | headers.emplace("x-amz-server-side-encryption-customer-key-md5" , ss.str()); |
154 | ss.str("" ); |
155 | } |
156 | |
157 | if(m_copySourceSSECustomerAlgorithmHasBeenSet) |
158 | { |
159 | ss << m_copySourceSSECustomerAlgorithm; |
160 | headers.emplace("x-amz-copy-source-server-side-encryption-customer-algorithm" , ss.str()); |
161 | ss.str("" ); |
162 | } |
163 | |
164 | if(m_copySourceSSECustomerKeyHasBeenSet) |
165 | { |
166 | ss << m_copySourceSSECustomerKey; |
167 | headers.emplace("x-amz-copy-source-server-side-encryption-customer-key" , ss.str()); |
168 | ss.str("" ); |
169 | } |
170 | |
171 | if(m_copySourceSSECustomerKeyMD5HasBeenSet) |
172 | { |
173 | ss << m_copySourceSSECustomerKeyMD5; |
174 | headers.emplace("x-amz-copy-source-server-side-encryption-customer-key-md5" , ss.str()); |
175 | ss.str("" ); |
176 | } |
177 | |
178 | if(m_requestPayerHasBeenSet) |
179 | { |
180 | headers.emplace("x-amz-request-payer" , RequestPayerMapper::GetNameForRequestPayer(m_requestPayer)); |
181 | } |
182 | |
183 | return headers; |
184 | } |
185 | |