diff --git a/src/config/types.ts b/src/config/types.ts index b554650820..a3d55e2843 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -53,6 +53,7 @@ export type Source = { storage: string; bucket?: string; prefix?: string; + baseUrl?: string; config?: any; }; diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index dbb1224cd8..48f2388193 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -25,6 +25,8 @@ async function save(readable: stream.Readable, name: string, type: string, hash: const minio = new Minio.Client(config.drive.config); const id = uuid.v4(); const obj = `${config.drive.prefix}/${id}`; + const baseUrl = config.drive.baseUrl + || `${ config.drive.config.secure ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? ':' + config.drive.config.port : '' }/${ config.drive.bucket }`; await minio.putObject(config.drive.bucket, obj, readable, size, { 'Content-Type': type, 'Cache-Control': 'max-age=31536000, immutable' }); Object.assign(metadata, { @@ -33,7 +35,7 @@ async function save(readable: stream.Readable, name: string, type: string, hash: storageProps: { id: id }, - url: `${ config.drive.config.secure ? 'https' : 'http' }://${ config.drive.config.endPoint }${ config.drive.config.port ? ':' + config.drive.config.port : '' }/${ config.drive.bucket }/${ obj }` + url: `${ baseUrl }/${ obj }` }); const file = await DriveFile.insert({