mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-29 09:23:04 +00:00
Add config.drive.baseUrl
This commit is contained in:
parent
e8783b15b1
commit
8ef38ebab1
2 changed files with 4 additions and 1 deletions
|
@ -53,6 +53,7 @@ export type Source = {
|
||||||
storage: string;
|
storage: string;
|
||||||
bucket?: string;
|
bucket?: string;
|
||||||
prefix?: string;
|
prefix?: string;
|
||||||
|
baseUrl?: string;
|
||||||
config?: any;
|
config?: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ async function save(readable: stream.Readable, name: string, type: string, hash:
|
||||||
const minio = new Minio.Client(config.drive.config);
|
const minio = new Minio.Client(config.drive.config);
|
||||||
const id = uuid.v4();
|
const id = uuid.v4();
|
||||||
const obj = `${config.drive.prefix}/${id}`;
|
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' });
|
await minio.putObject(config.drive.bucket, obj, readable, size, { 'Content-Type': type, 'Cache-Control': 'max-age=31536000, immutable' });
|
||||||
|
|
||||||
Object.assign(metadata, {
|
Object.assign(metadata, {
|
||||||
|
@ -33,7 +35,7 @@ async function save(readable: stream.Readable, name: string, type: string, hash:
|
||||||
storageProps: {
|
storageProps: {
|
||||||
id: id
|
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({
|
const file = await DriveFile.insert({
|
||||||
|
|
Loading…
Reference in a new issue