MCPcopy
hub / github.com/scality/cloudserver / putPart

Function putPart

tests/multipleBackend/objectPutPart.js:54–154  ·  view source on GitHub ↗
(bucketLoc, mpuLoc, requestHost, cb,
errorDescription)

Source from the content-addressed store, hash-verified

52}
53
54function putPart(bucketLoc, mpuLoc, requestHost, cb,
55errorDescription) {
56 const objectName = `objectName-${Date.now()}`;
57 const post = bucketLoc ? '<?xml version="1.0" encoding="UTF-8"?>' +
58 '<CreateBucketConfiguration ' +
59 'xmlns="http://s3.amazonaws.com/doc/2006-03-01/">' +
60 `<LocationConstraint>${bucketLoc}</LocationConstraint>` +
61 '</CreateBucketConfiguration>' : '';
62 const bucketPutReq = {
63 bucketName,
64 namespace,
65 headers: { host: `${bucketName}.s3.amazonaws.com` },
66 url: '/',
67 post,
68 };
69 if (requestHost) {
70 bucketPutReq.parsedHost = requestHost;
71 }
72 const initiateReq = {
73 bucketName,
74 namespace,
75 objectKey: objectName,
76 headers: { host: `${bucketName}.s3.amazonaws.com` },
77 url: `/${objectName}?uploads`,
78 actionImplicitDenies: false,
79 };
80 if (mpuLoc) {
81 initiateReq.headers = { 'host': `${bucketName}.s3.amazonaws.com`,
82 'x-amz-meta-scal-location-constraint': `${mpuLoc}` };
83 }
84 if (requestHost) {
85 initiateReq.parsedHost = requestHost;
86 }
87 async.waterfall([
88 next => {
89 bucketPut(authInfo, bucketPutReq, log, err => {
90 assert.ifError(err, 'Error putting bucket');
91 next(err);
92 });
93 },
94 next => {
95 initiateMultipartUpload(authInfo, initiateReq, log, next);
96 },
97 (result, corsHeaders, next) => {
98 const mpuKeys = metadata.keyMaps.get(mpuBucket);
99 assert.strictEqual(mpuKeys.size, 1);
100 assert(mpuKeys.keys().next().value
101 .startsWith(`overview${splitter}${objectName}`));
102 parseString(result, next);
103 },
104 ],
105 (err, json) => {
106 if (errorDescription) {
107 assert.strictEqual(err.code, 400);
108 assert(err.is.InvalidArgument);
109 assert(err.description.indexOf(errorDescription) > -1);
110 return cb();
111 }

Callers 1

objectPutPart.jsFile · 0.70

Calls 3

bucketPutFunction · 0.85
objectPutPartFunction · 0.85
initiateMultipartUploadFunction · 0.50

Tested by

no test coverage detected