Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugin setting for minio CDN endpoint support #7305

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 10 additions & 14 deletions packages/nocodb/src/plugins/mino/Minio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ export default class Minio implements IStorageAdapterV2 {
// call S3 to retrieve upload file to specified bucket
this.minioClient
.putObject(this.input?.bucket, key, fileStream, metaData)
.then(() => {
resolve(
`http${this.input.useSSL ? 's' : ''}://${this.input.endPoint}:${
this.input.port
}/${this.input.bucket}/${key}`,
);
})
.then(() => resolve(this.getFileUrl(key)))
.catch(reject);
});
}
Expand Down Expand Up @@ -116,13 +110,7 @@ export default class Minio implements IStorageAdapterV2 {
// call S3 to retrieve upload file to specified bucket
this.minioClient
.putObject(this.input?.bucket, key, response.data, metaData)
.then(() => {
resolve(
`http${this.input.useSSL ? 's' : ''}://${this.input.endPoint}:${
this.input.port
}/${this.input.bucket}/${key}`,
);
})
.then(() => resolve(this.getFileUrl(key)))
.catch(reject);
})
.catch((error) => {
Expand All @@ -145,4 +133,12 @@ export default class Minio implements IStorageAdapterV2 {
getDirectoryList(_path: string): Promise<string[]> {
return Promise.resolve(undefined);
}

private getFileUrl(key: string): string {
let fileUrlPrefix = `http${this.input.useSSL ? 's' : ''}://${this.input.endPoint}:${this.input.port}`
if (this.input.cdnEndpoint) {
fileUrlPrefix = this.input.cdnEndpoint;
}
return `${fileUrlPrefix}/${key}`;
}
}
7 changes: 7 additions & 0 deletions packages/nocodb/src/plugins/mino/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ const config: XcPluginConfig = {
type: XcType.SingleLineText,
required: true,
},
{
key: 'cdnEndPoint',
label: 'Minio CDN Endpoint',
placeholder: 'https://example.com',
type: XcType.SingleLineText,
required: false,
},
{
key: 'port',
label: 'Port',
Expand Down