Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ export const maximumMetaHeadersSize = 2136;
export const emptyFileMd5 = 'd41d8cd98f00b204e9800998ecf8427e';
// Version 2 changes the format of the data location property
// Version 3 adds the dataStoreName attribute
export const mdModelVersion = 3;
// Version 3.1 backport of Version 7 on top of 3
// Version 7 adds the "bucketOwnerId" attribute to the object metadata.
// This is set when the owner of the bucket is different from the owner-id of the object.
// This can happen in cases of cross-account permissions where the object
// is uploaded by a different account than the one that owns the bucket.
export const mdModelVersion = 3.1;
/*
* Splitter is used to build the object name for the overview of a
* multipart upload and to build the object names for each part of a
Expand Down
32 changes: 32 additions & 0 deletions lib/models/ObjectMD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export type ReplicationInfo = {

export type ObjectMDData = {
'owner-display-name': string;
// The canonical Id of the account used to create the object.
// This can be different than the bucket owner if cross-account
// permissions are used to create the object.
'owner-id': string;
'cache-control': string;
'content-disposition': string;
Expand Down Expand Up @@ -73,6 +76,9 @@ export type ObjectMDData = {
replicationInfo: ReplicationInfo;
dataStoreName: string;
originOp: string;
// This is the canonical Id for the bucket owner.
// This is only set when it differs from `owner-id`.
bucketOwnerId?: string;
};

/**
Expand Down Expand Up @@ -1144,4 +1150,30 @@ export default class ObjectMD {
getValue() {
return this._data;
}

/**
* Set bucket owner id
* @param canonicalId - bucket owner id
* @return itself
*/
setBucketOwnerId(canonicalId: string) {
this._data.bucketOwnerId = canonicalId;
return this;
}

/**
* Returns bucket owner id
* @return bucket owner id
*/
getBucketOwnerId() {
return this._data.bucketOwnerId;
}

/**
* Returns the model version of the object metadata
* @return {number|undefined}
*/
getModelVersion(): number | undefined {
return this._data['md-model-version'];
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"engines": {
"node": ">=16"
},
"version": "7.70.46",
"version": "7.70.47",
"description": "Common utilities for the S3 project components",
"main": "build/index.js",
"repository": {
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/models/ObjectMD.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ describe('ObjectMD class setters/getters', () => {
['RetentionMode', 'GOVERNANCE'],
['RetentionDate', retainDate.toISOString()],
['OriginOp', null, ''],
['BucketOwnerId', null, undefined],
['BucketOwnerId', 'abcdef'],
['ModelVersion', null, constants.mdModelVersion],
].forEach(test => {
const property = test[0];
const testValue = test[1];
Expand Down
Loading