Compare commits

...

3 Commits

Author SHA1 Message Date
philipyoo 5659d8c01d objectCopy 2019-04-16 11:10:20 -07:00
philipyoo b7100d066d create mpu 2019-04-16 11:10:20 -07:00
philipyoo 2e1de7e070 objectPut, multiObjectDelete, objectDelete
Requires defining SOURCE_DEPLOYMENT on Zenko chart template
2019-04-16 10:42:16 -07:00
3 changed files with 53 additions and 0 deletions

View File

@ -19,6 +19,28 @@ const { externalBackends, versioningNotImplBackends } = constants;
const externalVersioningErrorMessage = 'We do not currently support putting ' + const externalVersioningErrorMessage = 'We do not currently support putting ' +
'a versioned object to a location-constraint of type Azure or GCP.'; 'a versioned object to a location-constraint of type Azure or GCP.';
// if the request occurs within a Zenko deployment, we place a user-metadata
// field on the object, including delete markers
function _placeZenkoStamp(request, metaHeaders, isDeleteMarker) {
const zenkoIdentifierHeader = 'x-amz-meta-zenko-source';
const userAgent = request.headers['user-agent'];
// if the request came from Zenko, add user-metadata on this delete marker
// for internal use
if (isDeleteMarker) {
if (userAgent && userAgent.includes('Zenko')) {
// eslint-disable-next-line no-param-reassign
metaHeaders[zenkoIdentifierHeader] = 'zenko';
}
} else {
if (process.env.REMOTE_MANAGEMENT_DISABLE === '0' &&
!metaHeaders[zenkoIdentifierHeader]) {
// eslint-disable-next-line no-param-reassign
metaHeaders[zenkoIdentifierHeader] = 'zenko';
}
}
}
function _storeInMDandDeleteData(bucketName, dataGetInfo, cipherBundle, function _storeInMDandDeleteData(bucketName, dataGetInfo, cipherBundle,
metadataStoreParams, dataToDelete, deleteLog, requestMethod, callback) { metadataStoreParams, dataToDelete, deleteLog, requestMethod, callback) {
@ -83,6 +105,9 @@ function createAndStoreObject(bucketName, bucketMD, objectKey, objMD, authInfo,
return process.nextTick(() => callback(metaHeaders)); return process.nextTick(() => callback(metaHeaders));
} }
_placeZenkoStamp(request, metaHeaders, isDeleteMarker);
console.log(`metaHeaders: ${JSON.stringify(metaHeaders)}`);
log.trace('meta headers', { metaHeaders, method: 'objectPut' }); log.trace('meta headers', { metaHeaders, method: 'objectPut' });
const objectKeyContext = { const objectKeyContext = {
bucketName, bucketName,

View File

@ -15,6 +15,18 @@ const validateWebsiteHeader = require('./apiUtils/object/websiteServing')
const monitoring = require('../utilities/monitoringHandler'); const monitoring = require('../utilities/monitoringHandler');
const { data } = require('../data/wrapper'); const { data } = require('../data/wrapper');
// if the request occurs within a Zenko deployment, we place a user-metadata
// field on the object
function _placeZenkoStamp(metaHeaders) {
const zenkoIdentifierHeader = 'x-amz-meta-zenko-source';
if (process.env.REMOTE_MANAGEMENT_DISABLE === '0' &&
!metaHeaders[zenkoIdentifierHeader]) {
// eslint-disable-next-line no-param-reassign
metaHeaders[zenkoIdentifierHeader] = 'zenko';
}
}
/* /*
Sample xml response: Sample xml response:
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
@ -64,6 +76,9 @@ function initiateMultipartUpload(authInfo, request, log, callback) {
}); });
return process.nextTick(() => callback(metaHeaders)); return process.nextTick(() => callback(metaHeaders));
} }
_placeZenkoStamp(metaHeaders);
// TODO: Add this as a utility function for all object put requests // TODO: Add this as a utility function for all object put requests
// but after authentication so that string to sign is not impacted // but after authentication so that string to sign is not impacted
// This is GH Issue#89 // This is GH Issue#89

View File

@ -28,6 +28,18 @@ const versioningNotImplBackends = constants.versioningNotImplBackends;
const externalVersioningErrorMessage = 'We do not currently support putting ' + const externalVersioningErrorMessage = 'We do not currently support putting ' +
'a versioned object to a location-constraint of type AWS or Azure or GCP.'; 'a versioned object to a location-constraint of type AWS or Azure or GCP.';
// if the request occurs within a Zenko deployment, we place a user-metadata
// field on the object
function _placeZenkoStamp(metaHeaders) {
const zenkoIdentifierHeader = 'x-amz-meta-zenko-source';
if (process.env.REMOTE_MANAGEMENT_DISABLE === '0' &&
!metaHeaders[zenkoIdentifierHeader]) {
// eslint-disable-next-line no-param-reassign
metaHeaders[zenkoIdentifierHeader] = 'zenko';
}
}
/** /**
* Preps metadata to be saved (based on copy or replace request header) * Preps metadata to be saved (based on copy or replace request header)
* @param {object} request - request * @param {object} request - request
@ -96,6 +108,7 @@ function _prepMetadata(request, sourceObjMD, headers, sourceIsDestination,
}); });
return { error: userMetadata }; return { error: userMetadata };
} }
_placeZenkoStamp(userMetadata);
// If metadataDirective is: // If metadataDirective is:
// - 'COPY' and source object has a location constraint in its metadata // - 'COPY' and source object has a location constraint in its metadata
// we use the bucket destination location constraint // we use the bucket destination location constraint