Skip to content

Commit 261fe01

Browse files
authored
fix meta data directive in copy object (#1151)
1 parent 838aa8f commit 261fe01

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/helpers.ts

+8
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export interface ICopyDestinationOptions {
174174
*/
175175
RetainUntilDate?: string
176176
Mode?: RETENTION_MODES
177+
MetadataDirective?: 'COPY' | 'REPLACE'
177178
}
178179

179180
export class CopyDestinationOptions {
@@ -185,6 +186,7 @@ export class CopyDestinationOptions {
185186
private readonly LegalHold?: 'on' | 'off'
186187
private readonly RetainUntilDate?: string
187188
private readonly Mode?: RETENTION_MODES
189+
private readonly MetadataDirective?: string
188190

189191
constructor({
190192
Bucket,
@@ -195,6 +197,7 @@ export class CopyDestinationOptions {
195197
LegalHold,
196198
RetainUntilDate,
197199
Mode,
200+
MetadataDirective,
198201
}: ICopyDestinationOptions) {
199202
this.Bucket = Bucket
200203
this.Object = Object
@@ -204,6 +207,7 @@ export class CopyDestinationOptions {
204207
this.LegalHold = LegalHold
205208
this.Mode = Mode // retention mode
206209
this.RetainUntilDate = RetainUntilDate
210+
this.MetadataDirective = MetadataDirective
207211
}
208212

209213
getHeaders(): RequestHeaders {
@@ -238,6 +242,10 @@ export class CopyDestinationOptions {
238242
}
239243
}
240244

245+
if (this.MetadataDirective) {
246+
headerOptions[`X-Amz-Metadata-Directive`] = this.MetadataDirective
247+
}
248+
241249
if (this.Encryption) {
242250
const encryptionHeaders = getEncryptionHeaders(this.Encryption)
243251
for (const [key, value] of Object.entries(encryptionHeaders)) {

0 commit comments

Comments
 (0)