MCPcopy Index your code
hub / github.com/scality/cloudserver / putMPU

Function putMPU

tests/unit/api/objectReplicationMD.js:165–204  ·  view source on GitHub ↗
(key, body, cb)

Source from the content-addressed store, hash-verified

163
164// Initiate an MPU, put a part with the given body, and complete the MPU.
165function putMPU(key, body, cb) {
166 const uploadId = '9a0364b9e99bb480dd25e1f0284c8555';
167 createShadowBucket(key, uploadId);
168 const partBody = Buffer.from(body, 'utf8');
169 const md5Hash = crypto.createHash('md5').update(partBody);
170 const calculatedHash = md5Hash.digest('hex');
171 const partKey = `${uploadId}${constants.splitter}00001`;
172 const obj = {
173 partLocations: [{
174 key: 1,
175 dataStoreName: 'scality-internal-mem',
176 dataStoreETag: `1:${calculatedHash}`,
177 }],
178 key: partKey,
179 };
180 obj['content-md5'] = calculatedHash;
181 obj['content-length'] = body.length;
182 metadata.keyMaps.get(mpuShadowBucket).set(partKey, new Map);
183 const partMap = metadata.keyMaps.get(mpuShadowBucket).get(partKey);
184 Object.assign(partMap, obj);
185 const postBody =
186 '<CompleteMultipartUpload>' +
187 '<Part>' +
188 '<PartNumber>1</PartNumber>' +
189 `<ETag>"${calculatedHash}"</ETag>` +
190 '</Part>' +
191 '</CompleteMultipartUpload>';
192 const req = {
193 bucketName,
194 namespace,
195 objectKey: key,
196 parsedHost: 's3.amazonaws.com',
197 url: `/${key}?uploadId=${uploadId}`,
198 headers: { host: `${bucketName}.s3.amazonaws.com` },
199 query: { uploadId },
200 post: postBody,
201 actionImplicitDenies: false,
202 };
203 return completeMultipartUpload(authInfo, req, log, cb);
204}
205
206// Copy an object where replication does not apply.
207function copyObject(sourceObjectKey, copyObjectKey, hasContent, cb) {

Callers 1

Calls 2

createShadowBucketFunction · 0.85
completeMultipartUploadFunction · 0.50

Tested by

no test coverage detected