in source/lambda/copyToDestinationBucket/lib/copy.js [29:56]
async function copyKeyToDestinationBucket(key, aid, uploadId, partNo, startByte, endByte) {
const currentStorageClass = await this.getKeyStorageClass(key)
// Staging bucket object must always be of STANDARD storage class
// If the entry does not exist - the file does not exist
if (!currentStorageClass) {
console.error(`${key} :
Unable to copy to the destination bucket as staging bucket doesn't have the specified file.
Can be false positive, when invoked on retry.
Please check the destination bucket.`);
}
if (uploadId == null) {
console.log(`Single part copy : ${key} : ${STORAGE_CLASS}`)
await s3.copyObject({
CopySource: encodeURIComponent(`${STAGING_BUCKET}/${STAGING_BUCKET_PREFIX}/${key}`),
Bucket: DESTINATION_BUCKET,
Key: key,
StorageClass: STORAGE_CLASS
}).promise();
await closeOffRecord(aid, key);
console.log(`Copy completed : ${key}`);
} else {
console.log(`Multi part copy for : ${key} - ${partNo}`);
await copyMultiPart(key, aid, uploadId, partNo, startByte, endByte);
}
}