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

Function objectMPU

tests/utapi/awsNodeSdk.js:128–173  ·  view source on GitHub ↗
(bucket, key, parts, partSize, callback)

Source from the content-addressed store, hash-verified

126}
127
128function objectMPU(bucket, key, parts, partSize, callback) {
129 let ETags = [];
130 let uploadId = null;
131 const partNumbers = Array.from(Array(parts).keys());
132 const initiateMPUParams = { Bucket: bucket, Key: key };
133 async.waterfall([
134 next => s3Client.send(new CreateMultipartUploadCommand(initiateMPUParams))
135 .then(data => {
136 uploadId = data.UploadId;
137 return next();
138 })
139 .catch(next),
140 next =>
141 async.mapLimit(partNumbers, 1, (partNumber, callback) => {
142 const body = Buffer.alloc(partSize);
143 const uploadPartParams = {
144 Bucket: bucket,
145 Key: key,
146 PartNumber: partNumber + 1,
147 UploadId: uploadId,
148 Body: body,
149 };
150 s3Client.send(new UploadPartCommand(uploadPartParams))
151 .then(data => callback(null, data.ETag))
152 .catch(callback);
153 }, (err, results) => {
154 if (err) {
155 return next(err);
156 }
157 ETags = results;
158 return next();
159 }),
160 next => {
161 const completeRequest = { Parts: partNumbers.map(n => ({ ETag: ETags[n], PartNumber: n + 1 })) };
162 const params = {
163 Bucket: bucket,
164 Key: key,
165 MultipartUpload: completeRequest,
166 UploadId: uploadId,
167 };
168 s3Client.send(new CompleteMultipartUploadCommand(params))
169 .then(data => next(null, data))
170 .catch(next);
171 },
172 ], callback);
173}
174
175function removeVersions(buckets, cb) {
176 async.each(buckets, (bucket, done) => removeAllVersions({ Bucket: bucket }, done), cb);

Callers 1

awsNodeSdk.jsFile · 0.70

Calls 1

sendMethod · 0.80

Tested by

no test coverage detected