mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-25 21:16:43 -06:00
ce340aba7a
* wip * wip * wip * wip * wip * Update define.ts * Update update.ts * Update user.ts * wip * wip * Update request.ts * URL * wip * wip * wip * wip * Update invite.ts * Update create.ts
24 lines
884 B
TypeScript
24 lines
884 B
TypeScript
import { URL } from 'url';
|
|
import * as S3 from 'aws-sdk/clients/s3';
|
|
import { Meta } from '../../models/entities/meta';
|
|
import { getAgentByUrl } from '@/misc/fetch';
|
|
|
|
export function getS3(meta: Meta) {
|
|
const u = meta.objectStorageEndpoint != null
|
|
? `${meta.objectStorageUseSSL ? 'https://' : 'http://'}${meta.objectStorageEndpoint}`
|
|
: `${meta.objectStorageUseSSL ? 'https://' : 'http://'}example.net`;
|
|
|
|
return new S3({
|
|
endpoint: meta.objectStorageEndpoint || undefined,
|
|
accessKeyId: meta.objectStorageAccessKey!,
|
|
secretAccessKey: meta.objectStorageSecretKey!,
|
|
region: meta.objectStorageRegion || undefined,
|
|
sslEnabled: meta.objectStorageUseSSL,
|
|
s3ForcePathStyle: !meta.objectStorageEndpoint // AWS with endPoint omitted
|
|
? false
|
|
: meta.objectStorageS3ForcePathStyle,
|
|
httpOptions: {
|
|
agent: getAgentByUrl(new URL(u), !meta.objectStorageUseProxy)
|
|
}
|
|
});
|
|
}
|