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

Function metadataValidateMultipart

lib/services.js:709–814  ·  view source on GitHub ↗

* Checks whether bucket exists, multipart upload * has been initiated and the user is authorized * @param {object} params - custom built object containing * bucket name, uploadId, authInfo etc. * @param {function} cb - callback containing error and * bucket reference for the

(params, cb)

Source from the content-addressed store, hash-verified

707 * - the overview key stored metadata
708 */
709 metadataValidateMultipart(params, cb) {
710 const { bucketName, uploadId, authInfo,
711 objectKey, requestType, log } = params;
712
713 assert.strictEqual(typeof bucketName, 'string');
714 // This checks whether the mpu bucket exists.
715 // If the MPU was initiated, the mpu bucket should exist.
716 const mpuBucketName = `${constants.mpuBucketPrefix}${bucketName}`;
717 metadata.getBucket(mpuBucketName, log, (err, mpuBucket) => {
718 if (err?.is?.NoSuchBucket) {
719 log.debug('bucket not found in metadata', { error: err,
720 method: 'services.metadataValidateMultipart' });
721 return cb(errors.NoSuchUpload);
722 }
723 if (err) {
724 log.error('error from metadata', { error: err,
725 method: 'services.metadataValidateMultipart' });
726 return cb(err);
727 }
728
729 let splitter = constants.splitter;
730 // BACKWARD: Remove to remove the old splitter
731 if (mpuBucket.getMdBucketModelVersion() < 2) {
732 splitter = constants.oldSplitter;
733 }
734 const mpuOverviewKey =
735 `overview${splitter}${objectKey}${splitter}${uploadId}`;
736
737 metadata.getObjectMD(mpuBucket.getName(), mpuOverviewKey,
738 {}, log, (err, storedMetadata) => {
739 if (err) {
740 if (err.is.NoSuchKey) {
741 return cb(errors.NoSuchUpload);
742 }
743 log.error('error from metadata', { error: err });
744 return cb(err);
745 }
746
747 const initiatorID = storedMetadata.initiator.ID;
748 const ownerID = storedMetadata['owner-id'];
749 const mpuOverview = {
750 key: storedMetadata.key,
751 id: storedMetadata.id,
752 eventualStorageBucket:
753 storedMetadata.eventualStorageBucket,
754 initiatorID,
755 initiatorDisplayName:
756 storedMetadata.initiator.DisplayName,
757 ownerID,
758 ownerDisplayName:
759 storedMetadata['owner-display-name'],
760 storageClass:
761 storedMetadata['x-amz-storage-class'],
762 initiated: storedMetadata.initiated,
763 controllingLocationConstraint:
764 storedMetadata.controllingLocationConstraint,
765 };
766

Callers

nothing calls this directly

Calls 3

debugMethod · 0.80
errorMethod · 0.80
getOwnerMethod · 0.80

Tested by

no test coverage detected