diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2020-03-14 11:33:19 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-14 11:33:19 +0900 |
| commit | a2d3d22b6e9e8bdcc8eab295b7d020540bb1e413 (patch) | |
| tree | effe79dc7a8c54ffe8494aa8d713cf33bfb10067 /src/services/drive | |
| parent | fix gif badge (#6153) (diff) | |
| download | sharkey-a2d3d22b6e9e8bdcc8eab295b7d020540bb1e413.tar.gz sharkey-a2d3d22b6e9e8bdcc8eab295b7d020540bb1e413.tar.bz2 sharkey-a2d3d22b6e9e8bdcc8eab295b7d020540bb1e413.zip | |
オブジェクトストレージでS3のvirtual-host形式のサポートなど (#6148)
* オブジェクトストレージでS3のvirtual-host形式のサポートなど
* 表記揺れ
* more simply
* S3ならばs3ForcePathStyleしない
Diffstat (limited to 'src/services/drive')
| -rw-r--r-- | src/services/drive/add-file.ts | 3 | ||||
| -rw-r--r-- | src/services/drive/s3.ts | 10 |
2 files changed, 7 insertions, 6 deletions
diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index 2931de6dc0..cf0951ebad 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -217,7 +217,8 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, type: string, 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) { diff --git a/src/services/drive/s3.ts b/src/services/drive/s3.ts index 95243d5901..d136bb2694 100644 --- a/src/services/drive/s3.ts +++ b/src/services/drive/s3.ts @@ -1,23 +1,23 @@ 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 { HttpsProxyAgent } from 'https-proxy-agent'; import * as agentkeepalive from 'agentkeepalive'; const httpsAgent = config.proxy - ? new httpsProxyAgent(config.proxy) + ? new HttpsProxyAgent(config.proxy) : new agentkeepalive.HttpsAgent({ freeSocketTimeout: 30 * 1000 }); export function getS3(meta: Meta) { const conf = { - endpoint: meta.objectStorageEndpoint, + endpoint: meta.objectStorageEndpoint || undefined, accessKeyId: meta.objectStorageAccessKey, secretAccessKey: meta.objectStorageSecretKey, - region: meta.objectStorageRegion, + region: meta.objectStorageRegion || undefined, sslEnabled: meta.objectStorageUseSSL, - s3ForcePathStyle: true, + s3ForcePathStyle: !!meta.objectStorageEndpoint, httpOptions: { } } as S3.ClientConfiguration; |