HTTPリクエストのKeep-AliveとPrxoy対応など (#5226)
* DriveのKeep-Alive, Proxy と APのProxy対応 * request系でKeep-Aliveするように * fix lookup-dns-cache.d.ts * remove debug output
This commit is contained in:
parent
831ca53b63
commit
14736620ec
11 changed files with 151 additions and 176 deletions
31
src/services/drive/s3.ts
Normal file
31
src/services/drive/s3.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import * as S3 from 'aws-sdk/clients/s3';
|
||||
import config from '../../config';
|
||||
import { Meta } from '../../models/entities/meta';
|
||||
import * as httpsProxyAgent from 'https-proxy-agent';
|
||||
import * as agentkeepalive from 'agentkeepalive';
|
||||
|
||||
const httpsAgent = config.proxy
|
||||
? new httpsProxyAgent(config.proxy)
|
||||
: new agentkeepalive.HttpsAgent({
|
||||
freeSocketTimeout: 30 * 1000
|
||||
});
|
||||
|
||||
export function getS3(meta: Meta) {
|
||||
const conf = {
|
||||
endpoint: meta.objectStorageEndpoint,
|
||||
accessKeyId: meta.objectStorageAccessKey,
|
||||
secretAccessKey: meta.objectStorageSecretKey,
|
||||
region: meta.objectStorageRegion,
|
||||
sslEnabled: meta.objectStorageUseSSL,
|
||||
httpOptions: {
|
||||
}
|
||||
} as S3.ClientConfiguration;
|
||||
|
||||
if (meta.objectStorageUseSSL) {
|
||||
conf.httpOptions!.agent = httpsAgent;
|
||||
}
|
||||
|
||||
const s3 = new S3(conf);
|
||||
|
||||
return s3;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue