diff --git a/global.d.ts b/global.d.ts index 8c76986..48855d9 100644 --- a/global.d.ts +++ b/global.d.ts @@ -2,6 +2,7 @@ declare type ResponseStream = { setContentType( type: string ): void; write( stream: string | Buffer ): void; end(): void; + metadata?: any; }; declare type StreamifyHandler = ( event: APIGatewayProxyEventV2, response: ResponseStream ) => Promise; diff --git a/src/lambda-handler.ts b/src/lambda-handler.ts index 9a22222..4325c41 100644 --- a/src/lambda-handler.ts +++ b/src/lambda-handler.ts @@ -97,6 +97,7 @@ if ( typeof awslambda === 'undefined' ) { from( response: ResponseStream, metadata: { headers?: Record, } ): ResponseStream { + response.metadata = metadata; return response; }, }, diff --git a/tests/test-private-upload.ts b/tests/test-private-upload.ts index b54cad1..e7e6bf1 100644 --- a/tests/test-private-upload.ts +++ b/tests/test-private-upload.ts @@ -74,6 +74,9 @@ test( 'Test get private upload', async () => { * End the response. */ end(): void { + if ( this.metadata.headers['Cache-Control'] ) { + contentType = this.metadata.headers['Content-Type']; + } }, } ); @@ -115,6 +118,9 @@ test( 'Test get private upload with presign params', async () => { * End the response. */ end(): void { + if ( this.metadata.headers['Cache-Control'] ) { + contentType = this.metadata.headers['Content-Type']; + } }, } );