From 4f6c1d25fcb208275ca1cc0d3d1b104af24a11fc Mon Sep 17 00:00:00 2001 From: tdurieux Date: Mon, 8 May 2023 14:14:19 +0200 Subject: [PATCH] fix: always send a response --- src/storage/S3.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/storage/S3.ts b/src/storage/S3.ts index 610ae07..4b9abfa 100644 --- a/src/storage/S3.ts +++ b/src/storage/S3.ts @@ -108,7 +108,6 @@ export default class S3Storage implements StorageBase { Key: p, }); const s = await this.client().send(command); - s.ContentLength; res.status(200); if (s.ContentType) { res.contentType(s.ContentType); @@ -116,7 +115,11 @@ export default class S3Storage implements StorageBase { if (s.ContentLength) { res.set("Content-Length", s.ContentLength.toString()); } - (s.Body as Readable)?.pipe(res); + if (s.Body) { + (s.Body as Readable)?.pipe(res); + } else { + res.end(); + } } catch (error) { try { res.status(500);