2019-07-28 02:49:02 +02:00
|
|
|
import * as S3 from 'aws-sdk/clients/s3';
|
|
|
|
import { Meta } from '../../models/entities/meta';
|
2020-04-09 16:42:23 +02:00
|
|
|
import { httpsAgent, httpAgent } from '../../misc/fetch';
|
2019-07-28 02:49:02 +02:00
|
|
|
|
|
|
|
export function getS3(meta: Meta) {
|
2020-04-09 16:42:23 +02:00
|
|
|
return new S3({
|
2020-03-14 03:33:19 +01:00
|
|
|
endpoint: meta.objectStorageEndpoint || undefined,
|
2020-04-09 16:42:23 +02:00
|
|
|
accessKeyId: meta.objectStorageAccessKey!,
|
|
|
|
secretAccessKey: meta.objectStorageSecretKey!,
|
2020-03-14 03:33:19 +01:00
|
|
|
region: meta.objectStorageRegion || undefined,
|
2019-07-28 02:49:02 +02:00
|
|
|
sslEnabled: meta.objectStorageUseSSL,
|
2020-03-14 03:33:19 +01:00
|
|
|
s3ForcePathStyle: !!meta.objectStorageEndpoint,
|
2019-07-28 02:49:02 +02:00
|
|
|
httpOptions: {
|
2020-04-09 16:42:23 +02:00
|
|
|
agent: meta.objectStorageUseSSL ? httpsAgent : httpAgent
|
2019-07-28 02:49:02 +02:00
|
|
|
}
|
2020-04-09 16:42:23 +02:00
|
|
|
});
|
2019-07-28 02:49:02 +02:00
|
|
|
}
|