Skip to content

Commit

Permalink
S3のAgent判定に実endpointを使用するように
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Mar 11, 2023
1 parent 9f1f104 commit b650bd3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/drive/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { getAgentByUrl } from '../../misc/fetch';
export function getS3Client(drive: DriveConfig) {
if (drive.config == null) throw 'drive.config is null';

// dummy for selecting agent
const h = drive.config.endPoint || 'example.net';
const bypassProxy = drive.config.useProxy === undefined ? false : !drive.config.useProxy;

const config = {
endpoint: drive.config.endPoint ? `${drive.config.useSSL ? 'https://' : 'http://'}${drive.config.endPoint}` : undefined,
credentials: {
Expand All @@ -18,8 +22,8 @@ export function getS3Client(drive: DriveConfig) {
? false
: drive.config.s3ForcePathStyle == null ? true : !!drive.config.s3ForcePathStyle,
requestHandler: new NodeHttpHandler({
httpAgent: getAgentByUrl(new URL('http://example.net'), drive.config.useProxy === undefined ? false : !drive.config.useProxy) as any,
httpsAgent: getAgentByUrl(new URL('https://example.net'), drive.config.useProxy === undefined ? false : !drive.config.useProxy) as any,
httpAgent: getAgentByUrl(new URL(`http://${h}`), bypassProxy) as any,
httpsAgent: getAgentByUrl(new URL(`https://${h}`), bypassProxy) as any,
connectionTimeout: 10 * 1000,
socketTimeout: 30 * 1000,
}),
Expand Down

0 comments on commit b650bd3

Please sign in to comment.