misskey/src/services/drive/s3.ts
MeiMei d3c0f3c251
Use node-fetch instead of request (#6228)
* requestをnode-fetchになど

* format

* fix error

* t

* Fix test
2020-04-09 23:42:23 +09:00

17 lines
579 B
TypeScript

import * as S3 from 'aws-sdk/clients/s3';
import { Meta } from '../../models/entities/meta';
import { httpsAgent, httpAgent } from '../../misc/fetch';
export function getS3(meta: Meta) {
return new S3({
endpoint: meta.objectStorageEndpoint || undefined,
accessKeyId: meta.objectStorageAccessKey!,
secretAccessKey: meta.objectStorageSecretKey!,
region: meta.objectStorageRegion || undefined,
sslEnabled: meta.objectStorageUseSSL,
s3ForcePathStyle: !!meta.objectStorageEndpoint,
httpOptions: {
agent: meta.objectStorageUseSSL ? httpsAgent : httpAgent
}
});
}