Skip to content

Commit

Permalink
fix meta data directive in copy object (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
prakashsvmx authored May 18, 2023
1 parent 838aa8f commit 261fe01
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export interface ICopyDestinationOptions {
*/
RetainUntilDate?: string
Mode?: RETENTION_MODES
MetadataDirective?: 'COPY' | 'REPLACE'
}

export class CopyDestinationOptions {
Expand All @@ -185,6 +186,7 @@ export class CopyDestinationOptions {
private readonly LegalHold?: 'on' | 'off'
private readonly RetainUntilDate?: string
private readonly Mode?: RETENTION_MODES
private readonly MetadataDirective?: string

constructor({
Bucket,
Expand All @@ -195,6 +197,7 @@ export class CopyDestinationOptions {
LegalHold,
RetainUntilDate,
Mode,
MetadataDirective,
}: ICopyDestinationOptions) {
this.Bucket = Bucket
this.Object = Object
Expand All @@ -204,6 +207,7 @@ export class CopyDestinationOptions {
this.LegalHold = LegalHold
this.Mode = Mode // retention mode
this.RetainUntilDate = RetainUntilDate
this.MetadataDirective = MetadataDirective
}

getHeaders(): RequestHeaders {
Expand Down Expand Up @@ -238,6 +242,10 @@ export class CopyDestinationOptions {
}
}

if (this.MetadataDirective) {
headerOptions[`X-Amz-Metadata-Directive`] = this.MetadataDirective
}

if (this.Encryption) {
const encryptionHeaders = getEncryptionHeaders(this.Encryption)
for (const [key, value] of Object.entries(encryptionHeaders)) {
Expand Down

0 comments on commit 261fe01

Please sign in to comment.