From 261fe01388b8ed72fdca1f761ccfbf3b951ecf83 Mon Sep 17 00:00:00 2001 From: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com> Date: Thu, 18 May 2023 17:11:49 +0530 Subject: [PATCH] fix meta data directive in copy object (#1151) --- src/helpers.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/helpers.ts b/src/helpers.ts index 4751c9b7..7d0624ee 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -174,6 +174,7 @@ export interface ICopyDestinationOptions { */ RetainUntilDate?: string Mode?: RETENTION_MODES + MetadataDirective?: 'COPY' | 'REPLACE' } export class CopyDestinationOptions { @@ -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, @@ -195,6 +197,7 @@ export class CopyDestinationOptions { LegalHold, RetainUntilDate, Mode, + MetadataDirective, }: ICopyDestinationOptions) { this.Bucket = Bucket this.Object = Object @@ -204,6 +207,7 @@ export class CopyDestinationOptions { this.LegalHold = LegalHold this.Mode = Mode // retention mode this.RetainUntilDate = RetainUntilDate + this.MetadataDirective = MetadataDirective } getHeaders(): RequestHeaders { @@ -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)) {