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

Function setArchiveInfoHeaders

lib/api/apiUtils/object/coldStorage.js:42–72  ·  view source on GitHub ↗

* set archiveInfo headers to target header object * @param {object} objMD - object metadata * @returns {object} headers - target header object

(objMD)

Source from the content-addressed store, hash-verified

40 * @returns {object} headers - target header object
41 */
42function setArchiveInfoHeaders(objMD) {
43 const headers = {};
44
45 if (objMD['x-amz-scal-transition-in-progress']) {
46 headers['x-amz-scal-transition-in-progress'] = true;
47 headers['x-amz-scal-transition-time'] = new Date(objMD['x-amz-scal-transition-time']).toUTCString();
48 }
49
50 if (objMD.archive) {
51 headers['x-amz-scal-archive-info'] = JSON.stringify(objMD.archive.archiveInfo);
52
53 if (objMD.archive.restoreRequestedAt) {
54 headers['x-amz-scal-restore-requested-at'] = new Date(objMD.archive.restoreRequestedAt).toUTCString();
55 headers['x-amz-scal-restore-requested-days'] = objMD.archive.restoreRequestedDays;
56 }
57
58 if (objMD.archive.restoreCompletedAt) {
59 headers['x-amz-scal-restore-completed-at'] = new Date(objMD.archive.restoreCompletedAt).toUTCString();
60 headers['x-amz-scal-restore-will-expire-at'] = new Date(objMD.archive.restoreWillExpireAt).toUTCString();
61 headers['x-amz-scal-restore-etag'] = objMD['x-amz-restore']?.['content-md5'];
62 }
63 }
64
65 // Always get the "real" storage class (even when STANDARD) in this case
66 headers['x-amz-storage-class'] = objMD['x-amz-storage-class'] || objMD.dataStoreName;
67
68 // Get the owner-id
69 headers['x-amz-scal-owner-id'] = objMD['owner-id'];
70
71 return headers;
72}
73
74/**
75 * Check if restore can be done.

Callers 1

objectHeadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected