オブジェクトストレージでS3のvirtual-host形式のサポートなど (#6148)
* オブジェクトストレージでS3のvirtual-host形式のサポートなど * 表記揺れ * more simply * S3ならばs3ForcePathStyleしない
This commit is contained in:
parent
1ad8603cc2
commit
a2d3d22b6e
5 changed files with 27 additions and 15 deletions
|
@ -423,6 +423,18 @@ hideThisNote: "このノートを非表示"
|
||||||
showFeaturedNotesInTimeline: "タイムラインにおすすめのノートを表示する"
|
showFeaturedNotesInTimeline: "タイムラインにおすすめのノートを表示する"
|
||||||
objectStorage: "オブジェクトストレージ"
|
objectStorage: "オブジェクトストレージ"
|
||||||
useObjectStorage: "オブジェクトストレージを使用"
|
useObjectStorage: "オブジェクトストレージを使用"
|
||||||
|
objectStorageBaseUrl: "Base URL"
|
||||||
|
objectStorageBaseUrlDesc: "参照に使用するURL。CDNやProxyを使用している場合はそのURL、S3: 'https://<bucket>.s3.amazonaws.com'、GCS等: 'https://storage.googleapis.com/<bucket>'。"
|
||||||
|
objectStorageBucket: "Bucket"
|
||||||
|
objectStorageBucketDesc: "使用サービスのbucket名を指定してください。"
|
||||||
|
objectStoragePrefix: "Prefix"
|
||||||
|
objectStoragePrefixDesc: "このprefixのディレクトリ下に格納されます。"
|
||||||
|
objectStorageEndpoint: "Endpoint"
|
||||||
|
objectStorageEndpointDesc: "S3の場合は空、それ以外の場合は各サービスのendpointを指定してください。'<host>'または'<host>:<port>'のように指定します。"
|
||||||
|
objectStorageRegion: "Region"
|
||||||
|
objectStorageRegionDesc: "'xx-east-1'のようなregionを指定してください。使用サービスにregionの概念がない場合は、空または'us-east-1'にしてください。"
|
||||||
|
objectStorageUseSSL: "SSLを使用する"
|
||||||
|
objectStorageUseSSLDesc: "API接続にhttpsを使用しない場合はオフにしてください"
|
||||||
serverLogs: "サーバーログ"
|
serverLogs: "サーバーログ"
|
||||||
deleteAll: "全て削除"
|
deleteAll: "全て削除"
|
||||||
showFixedPostForm: "タイムライン上部に投稿フォームを表示する"
|
showFixedPostForm: "タイムライン上部に投稿フォームを表示する"
|
||||||
|
|
|
@ -102,21 +102,20 @@
|
||||||
<div class="_content">
|
<div class="_content">
|
||||||
<mk-switch v-model="useObjectStorage">{{ $t('useObjectStorage') }}</mk-switch>
|
<mk-switch v-model="useObjectStorage">{{ $t('useObjectStorage') }}</mk-switch>
|
||||||
<template v-if="useObjectStorage">
|
<template v-if="useObjectStorage">
|
||||||
<mk-input v-model="objectStorageBaseUrl" :disabled="!useObjectStorage">URL</mk-input>
|
<mk-input v-model="objectStorageBaseUrl" :disabled="!useObjectStorage">{{ $t('objectStorageBaseUrl') }}<template #desc>{{ $t('objectStorageBaseUrlDesc') }}</template></mk-input>
|
||||||
<div class="_inputs">
|
<div class="_inputs">
|
||||||
<mk-input v-model="objectStorageBucket" :disabled="!useObjectStorage">Bucket</mk-input>
|
<mk-input v-model="objectStorageBucket" :disabled="!useObjectStorage">{{ $t('objectStorageBucket') }}<template #desc>{{ $t('objectStorageBucketDesc') }}</template></mk-input>
|
||||||
<mk-input v-model="objectStoragePrefix" :disabled="!useObjectStorage">Prefix</mk-input>
|
<mk-input v-model="objectStoragePrefix" :disabled="!useObjectStorage">{{ $t('objectStoragePrefix') }}<template #desc>{{ $t('objectStoragePrefixDesc') }}</template></mk-input>
|
||||||
</div>
|
</div>
|
||||||
<mk-input v-model="objectStorageEndpoint" :disabled="!useObjectStorage">Endpoint</mk-input>
|
<mk-input v-model="objectStorageEndpoint" :disabled="!useObjectStorage">{{ $t('objectStorageEndpoint') }}<template #desc>{{ $t('objectStorageEndpointDesc') }}</template></mk-input>
|
||||||
<div class="_inputs">
|
<div class="_inputs">
|
||||||
<mk-input v-model="objectStorageRegion" :disabled="!useObjectStorage">Region</mk-input>
|
<mk-input v-model="objectStorageRegion" :disabled="!useObjectStorage">{{ $t('objectStorageRegion') }}<template #desc>{{ $t('objectStorageRegionDesc') }}</template></mk-input>
|
||||||
<mk-input v-model="objectStoragePort" type="number" :disabled="!useObjectStorage">Port</mk-input>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="_inputs">
|
<div class="_inputs">
|
||||||
<mk-input v-model="objectStorageAccessKey" :disabled="!useObjectStorage"><template #icon><fa :icon="faKey"/></template>Access key</mk-input>
|
<mk-input v-model="objectStorageAccessKey" :disabled="!useObjectStorage"><template #icon><fa :icon="faKey"/></template>Access key</mk-input>
|
||||||
<mk-input v-model="objectStorageSecretKey" :disabled="!useObjectStorage"><template #icon><fa :icon="faKey"/></template>Secret key</mk-input>
|
<mk-input v-model="objectStorageSecretKey" :disabled="!useObjectStorage"><template #icon><fa :icon="faKey"/></template>Secret key</mk-input>
|
||||||
</div>
|
</div>
|
||||||
<mk-switch v-model="objectStorageUseSSL" :disabled="!useObjectStorage">SSL</mk-switch>
|
<mk-switch v-model="objectStorageUseSSL" :disabled="!useObjectStorage">{{ $t('objectStorageUseSSL') }}<template #desc>{{ $t('objectStorageUseSSLDesc') }}</template></mk-switch>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div class="_footer">
|
<div class="_footer">
|
||||||
|
|
|
@ -7,10 +7,10 @@ import config from '../../config';
|
||||||
import { ILocalUser } from '../../models/entities/user';
|
import { ILocalUser } from '../../models/entities/user';
|
||||||
import { UserKeypairs } from '../../models';
|
import { UserKeypairs } from '../../models';
|
||||||
import { ensure } from '../../prelude/ensure';
|
import { ensure } from '../../prelude/ensure';
|
||||||
import * as httpsProxyAgent from 'https-proxy-agent';
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
||||||
|
|
||||||
const agent = config.proxy
|
const agent = config.proxy
|
||||||
? new httpsProxyAgent(config.proxy)
|
? new HttpsProxyAgent(config.proxy)
|
||||||
: new https.Agent({
|
: new https.Agent({
|
||||||
lookup: cache.lookup,
|
lookup: cache.lookup,
|
||||||
});
|
});
|
||||||
|
|
|
@ -217,7 +217,8 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string,
|
||||||
|
|
||||||
const upload = s3.upload(params);
|
const upload = s3.upload(params);
|
||||||
|
|
||||||
await upload.promise();
|
const result = await upload.promise();
|
||||||
|
if (result) logger.debug(`Uploaded: ${result.Bucket}/${result.Key} => ${result.Location}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteOldFile(user: IRemoteUser) {
|
async function deleteOldFile(user: IRemoteUser) {
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
import * as S3 from 'aws-sdk/clients/s3';
|
import * as S3 from 'aws-sdk/clients/s3';
|
||||||
import config from '../../config';
|
import config from '../../config';
|
||||||
import { Meta } from '../../models/entities/meta';
|
import { Meta } from '../../models/entities/meta';
|
||||||
import * as httpsProxyAgent from 'https-proxy-agent';
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
||||||
import * as agentkeepalive from 'agentkeepalive';
|
import * as agentkeepalive from 'agentkeepalive';
|
||||||
|
|
||||||
const httpsAgent = config.proxy
|
const httpsAgent = config.proxy
|
||||||
? new httpsProxyAgent(config.proxy)
|
? new HttpsProxyAgent(config.proxy)
|
||||||
: new agentkeepalive.HttpsAgent({
|
: new agentkeepalive.HttpsAgent({
|
||||||
freeSocketTimeout: 30 * 1000
|
freeSocketTimeout: 30 * 1000
|
||||||
});
|
});
|
||||||
|
|
||||||
export function getS3(meta: Meta) {
|
export function getS3(meta: Meta) {
|
||||||
const conf = {
|
const conf = {
|
||||||
endpoint: meta.objectStorageEndpoint,
|
endpoint: meta.objectStorageEndpoint || undefined,
|
||||||
accessKeyId: meta.objectStorageAccessKey,
|
accessKeyId: meta.objectStorageAccessKey,
|
||||||
secretAccessKey: meta.objectStorageSecretKey,
|
secretAccessKey: meta.objectStorageSecretKey,
|
||||||
region: meta.objectStorageRegion,
|
region: meta.objectStorageRegion || undefined,
|
||||||
sslEnabled: meta.objectStorageUseSSL,
|
sslEnabled: meta.objectStorageUseSSL,
|
||||||
s3ForcePathStyle: true,
|
s3ForcePathStyle: !!meta.objectStorageEndpoint,
|
||||||
httpOptions: {
|
httpOptions: {
|
||||||
}
|
}
|
||||||
} as S3.ClientConfiguration;
|
} as S3.ClientConfiguration;
|
||||||
|
|
Loading…
Reference in a new issue