Skip to content

Commit 641df31

Browse files
authored
[Fix] Change S3 logger to accept more authorization methods for AWS (#4114)
* Change S3 logger to accept more authorization methods for AWS * Lint fix
1 parent bde9e54 commit 641df31

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/server/src/utils/logger.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,23 @@ if (process.env.STORAGE_TYPE === 's3') {
2121
const customURL = process.env.S3_ENDPOINT_URL
2222
const forcePathStyle = process.env.S3_FORCE_PATH_STYLE === 'true'
2323

24+
if (!region || !s3Bucket) {
25+
throw new Error('S3 storage configuration is missing')
26+
}
27+
28+
let credentials: S3ClientConfig['credentials'] | undefined
29+
if (accessKeyId && secretAccessKey) {
30+
credentials = {
31+
accessKeyId,
32+
secretAccessKey
33+
}
34+
}
35+
2436
const s3Config: S3ClientConfig = {
2537
region: region,
2638
endpoint: customURL,
2739
forcePathStyle: forcePathStyle,
28-
credentials: {
29-
accessKeyId: accessKeyId as string,
30-
secretAccessKey: secretAccessKey as string
31-
}
40+
credentials: credentials
3241
}
3342

3443
s3ServerStream = new S3StreamLogger({

0 commit comments

Comments
 (0)