From 43f832dd6be59f371cf2ee232c57b213b1fe405b Mon Sep 17 00:00:00 2001 From: tdurieux Date: Thu, 9 Sep 2021 13:02:46 +0200 Subject: [PATCH] create a new s3 client for each request --- src/storage/S3.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/storage/S3.ts b/src/storage/S3.ts index b712975..a1c6eb8 100644 --- a/src/storage/S3.ts +++ b/src/storage/S3.ts @@ -2,7 +2,6 @@ import { StorageBase, Tree, TreeFile } from "../types"; import { S3 } from "aws-sdk"; import config from "../../config"; import * as stream from "stream"; -import { promisify } from "util"; import { ArchiveStreamToS3 } from "archive-stream-to-s3"; import * as express from "express"; import * as mime from "mime-types"; @@ -17,14 +16,16 @@ const originalArchiveStreamToS3Entry: Function = (ArchiveStreamToS3 as any) export default class S3Storage implements StorageBase { type = "AWS"; - client: S3; constructor() { if (!config.S3_BUCKET) throw new AnonymousError("s3_config_not_provided", { httpStatus: 500, }); - this.client = new S3({ + } + + get client() { + return new S3({ region: config.S3_REGION, endpoint: config.S3_ENDPOINT, accessKeyId: config.S3_CLIENT_ID,