in source/ingest/lib/index.js [434:460]
async findMd5(data) {
/* #1: x-amz-metadat-md5 is set, we are all good */
if (((data || {}).Metadata || {}).md5) {
return data.Metadata.md5;
}
/* #2: try object tagging */
const src = (this.stateData.input || {}).src || this.stateData.event;
const response = await CommonUtils.getTags(src.bucket, src.key).catch(() => undefined);
const chksum = ((response || {}).TagSet || []).find(x =>
x.Key === 'computed-md5');
if (chksum && chksum.Value.match(/^([0-9a-fA-F]{32})$/)) {
return chksum.Value;
}
/* #3: try ETag iff it is NOT multipart upload and SSE is disable or AES256 */
if (!data.ServerSideEncryption
|| data.ServerSideEncryption.toLowerCase() === 'aes256') {
/* the regex screens any multipart upload ETag */
const matched = data.ETag.match(/^"([0-9a-fA-F]{32})"$/);
if (matched) {
return matched[1];
}
}
return undefined;
}