-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetObjectAttributes.ts
More file actions
45 lines (38 loc) · 1.54 KB
/
getObjectAttributes.ts
File metadata and controls
45 lines (38 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import {
GetObjectAttributesCommand,
GetObjectAttributesCommandInput,
GetObjectAttributesCommandOutput,
ObjectAttributes,
} from '@aws-sdk/client-s3';
import {
overrideObjectAttributesHeaderMiddleware,
captureResponseBodyMiddleware,
parseUserMetadataMiddleware,
} from './utils';
export interface GetObjectAttributesExtendedInput extends Omit<GetObjectAttributesCommandInput, 'ObjectAttributes'> {
ObjectAttributes: (ObjectAttributes | `x-amz-meta-${string}`)[];
}
export interface GetObjectAttributesExtendedOutput extends GetObjectAttributesCommandOutput {
[key: `x-amz-meta-${string}`]: string;
}
export class GetObjectAttributesExtendedCommand extends GetObjectAttributesCommand {
constructor(input: GetObjectAttributesExtendedInput) {
super(input as GetObjectAttributesCommandInput);
const captured = { xml: '' };
this.middlewareStack.add(
overrideObjectAttributesHeaderMiddleware('x-amz-object-attributes', input.ObjectAttributes), {
step: 'build',
name: 'overrideObjectAttributesHeader',
});
this.middlewareStack.add(captureResponseBodyMiddleware(captured), {
step: 'deserialize',
name: 'captureResponseBody',
priority: 'low', // runs before SDK deserializer
});
this.middlewareStack.add(parseUserMetadataMiddleware(captured), {
step: 'deserialize',
name: 'parseUserMetadata',
priority: 'high', // runs after SDK deserializer
});
}
}