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

Function putData

lib/routes/routeBackbeat.js:394–481  ·  view source on GitHub ↗
(request, response, bucketInfo, objMd, log, callback)

Source from the content-addressed store, hash-verified

392}
393
394function putData(request, response, bucketInfo, objMd, log, callback) {
395 if (request.serverAccessLog) {
396 // eslint-disable-next-line no-param-reassign
397 request.serverAccessLog.replication = true;
398 }
399 let errMessage;
400 const canonicalID = request.headers['x-scal-canonical-id'];
401 if (canonicalID === undefined) {
402 errMessage = 'bad request: missing x-scal-canonical-id header';
403 log.error(errMessage);
404 return callback(errorInstances.BadRequest.customizeDescription(errMessage));
405 }
406 const contentMD5 = request.headers['content-md5'];
407 if (contentMD5 === undefined) {
408 errMessage = 'bad request: missing content-md5 header';
409 log.error(errMessage);
410 return callback(errorInstances.BadRequest.customizeDescription(errMessage));
411 }
412 const context = {
413 bucketName: request.bucketName,
414 owner: canonicalID,
415 namespace: NAMESPACE,
416 objectKey: request.objectKey,
417 };
418 const payloadLen = parseInt(request.headers['content-length'], 10);
419 const backendInfoObj = locationConstraintCheck(request, null, bucketInfo, log);
420 if (backendInfoObj.err) {
421 log.error('error getting backendInfo', {
422 error: backendInfoObj.err,
423 method: 'routeBackbeat',
424 });
425 return callback(errors.InternalError);
426 }
427 const backendInfo = backendInfoObj.backendInfo;
428 const isV2Request = request.query.v2 === '';
429 return createCipherBundle(bucketInfo, isV2Request, log, (err, cipherBundle) => {
430 if (err) {
431 log.error('error creating cipher bundle', {
432 error: err,
433 method: 'routeBackbeat',
434 });
435 return callback(errors.InternalError);
436 }
437 return dataStore(
438 context,
439 cipherBundle,
440 request,
441 payloadLen,
442 {},
443 backendInfo,
444 log,
445 (err, retrievalInfo, md5) => {
446 if (err) {
447 log.error('error putting data', {
448 error: err,
449 method: 'putData',
450 });
451 return callback(err);

Callers

nothing calls this directly

Calls 6

locationConstraintCheckFunction · 0.85
createCipherBundleFunction · 0.85
dataStoreFunction · 0.85
_respondWithHeadersFunction · 0.85
_respondFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected