From b6049c4ed2767e26a4a5ee2881ba040de73214ed Mon Sep 17 00:00:00 2001 From: tdurieux Date: Wed, 22 Feb 2023 08:39:23 +0100 Subject: [PATCH] feat: improve the error handling in s3 --- src/storage/S3.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/storage/S3.ts b/src/storage/S3.ts index e8765b9..99790ed 100644 --- a/src/storage/S3.ts +++ b/src/storage/S3.ts @@ -59,15 +59,7 @@ export default class S3Storage implements StorageBase { /** @override */ async mk(dir: string): Promise { - if (!config.S3_BUCKET) throw new Error("S3_BUCKET not set"); - if (dir && dir[dir.length - 1] != "/") dir = dir + "/"; - - await this.client - .putObject({ - Bucket: config.S3_BUCKET, - Key: dir, - }) - .promise(); + // no need to create folder on S3 } /** @override */ @@ -77,6 +69,7 @@ export default class S3Storage implements StorageBase { .listObjectsV2({ Bucket: config.S3_BUCKET, Prefix: dir, + MaxKeys: 1000, }) .promise(); @@ -114,7 +107,7 @@ export default class S3Storage implements StorageBase { try { res.status(error.statusCode || 500); } catch (err) { - console.error(err); + console.error(`[ERROR] S3 send ${p}`, err); } }) .on("httpHeaders", (statusCode, headers, response) => { @@ -170,6 +163,7 @@ export default class S3Storage implements StorageBase { .listObjectsV2({ Bucket: config.S3_BUCKET, Prefix: dir, + MaxKeys: 1000, }) .promise();