diff options
Diffstat (limited to 'server/lib/object-storage/shared')
-rw-r--r-- | server/lib/object-storage/shared/client.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/server/lib/object-storage/shared/client.ts b/server/lib/object-storage/shared/client.ts index c9a614593..d5cb074df 100644 --- a/server/lib/object-storage/shared/client.ts +++ b/server/lib/object-storage/shared/client.ts | |||
@@ -1,8 +1,22 @@ | |||
1 | import { S3Client } from '@aws-sdk/client-s3' | 1 | import { S3Client } from '@aws-sdk/client-s3' |
2 | import { NodeHttpHandler } from '@aws-sdk/node-http-handler' | ||
2 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { isProxyEnabled } from '@server/helpers/proxy' | ||
5 | import { getAgent } from '@server/helpers/requests' | ||
3 | import { CONFIG } from '@server/initializers/config' | 6 | import { CONFIG } from '@server/initializers/config' |
4 | import { lTags } from './logger' | 7 | import { lTags } from './logger' |
5 | 8 | ||
9 | function getProxyRequestHandler () { | ||
10 | if (!isProxyEnabled()) return null | ||
11 | |||
12 | const { agent } = getAgent() | ||
13 | |||
14 | return new NodeHttpHandler({ | ||
15 | httpAgent: agent.http, | ||
16 | httpsAgent: agent.https | ||
17 | }) | ||
18 | } | ||
19 | |||
6 | let endpointParsed: URL | 20 | let endpointParsed: URL |
7 | function getEndpointParsed () { | 21 | function getEndpointParsed () { |
8 | if (endpointParsed) return endpointParsed | 22 | if (endpointParsed) return endpointParsed |
@@ -26,7 +40,8 @@ function getClient () { | |||
26 | accessKeyId: OBJECT_STORAGE.CREDENTIALS.ACCESS_KEY_ID, | 40 | accessKeyId: OBJECT_STORAGE.CREDENTIALS.ACCESS_KEY_ID, |
27 | secretAccessKey: OBJECT_STORAGE.CREDENTIALS.SECRET_ACCESS_KEY | 41 | secretAccessKey: OBJECT_STORAGE.CREDENTIALS.SECRET_ACCESS_KEY |
28 | } | 42 | } |
29 | : undefined | 43 | : undefined, |
44 | requestHandler: getProxyRequestHandler() | ||
30 | }) | 45 | }) |
31 | 46 | ||
32 | logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, lTags()) | 47 | logger.info('Initialized S3 client %s with region %s.', getEndpoint(), OBJECT_STORAGE.REGION, lTags()) |