From 9137495eb3acf753d05f4d59bdacf7addceb897d Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 27 Oct 2022 13:26:37 +0800 Subject: [PATCH 1/3] feat(nocodb): revise backblaze form placeholders --- packages/nocodb/src/lib/plugins/backblaze/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/lib/plugins/backblaze/index.ts b/packages/nocodb/src/lib/plugins/backblaze/index.ts index 4a0e233bfa..cd952562b6 100644 --- a/packages/nocodb/src/lib/plugins/backblaze/index.ts +++ b/packages/nocodb/src/lib/plugins/backblaze/index.ts @@ -6,7 +6,7 @@ import BackblazePlugin from './BackblazePlugin'; const config: XcPluginConfig = { builder: BackblazePlugin, title: 'Backblaze B2', - version: '0.0.1', + version: '0.0.2', logo: 'plugins/backblaze.jpeg', tags: 'Storage', description: @@ -24,21 +24,21 @@ const config: XcPluginConfig = { { key: 'region', label: 'Region', - placeholder: 'Region', + placeholder: 'e.g. us-west-001', type: XcType.SingleLineText, required: true, }, { key: 'access_key', label: 'Access Key', - placeholder: 'Access Key', + placeholder: 'i.e. keyID in App Keys', type: XcType.SingleLineText, required: true, }, { key: 'access_secret', label: 'Access Secret', - placeholder: 'Access Secret', + placeholder: 'i.e. applicationKey in App Keys', type: XcType.Password, required: true, }, From 807b63a40b2b0fdee2fbc234f0f93f7f9b1cf6bb Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 27 Oct 2022 13:29:27 +0800 Subject: [PATCH 2/3] fix(nocodb): fix incorrect region format --- .../nocodb/src/lib/plugins/backblaze/Backblaze.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts b/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts index b1ea51ec73..d9db4aa033 100644 --- a/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts +++ b/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts @@ -73,6 +73,16 @@ export default class Backblaze implements IStorageAdapterV2 { }); } + patchRegion(region: string): string { + // in v0.0.1, we constructed the endpoint with `region = s3.us-west-001` + // in v0.0.2, `region` would be `us-west-001` + // as backblaze states Region is the 2nd part of your S3 Endpoint in documentation + if (region.slice(0, 3) === 's3.') { + region = region.slice(3); + } + return region; + } + public async fileDelete(_path: string): Promise { return Promise.resolve(undefined); } @@ -94,14 +104,14 @@ export default class Backblaze implements IStorageAdapterV2 { public async init(): Promise { const s3Options: any = { params: { Bucket: this.input.bucket }, - region: this.input.region, + region: this.patchRegion(this.input.region), }; s3Options.accessKeyId = this.input.access_key; s3Options.secretAccessKey = this.input.access_secret; s3Options.endpoint = new AWS.Endpoint( - `${this.input.region}.backblazeb2.com` + `s3.${s3Options.region}.backblazeb2.com` ); this.s3Client = new AWS.S3(s3Options); From 00b0f1686a1cce723caab9370e07c131192d3b30 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Thu, 27 Oct 2022 14:54:58 +0800 Subject: [PATCH 3/3] refactor(nocodb): use startsWith('s3.') --- packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts b/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts index d9db4aa033..16a757d081 100644 --- a/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts +++ b/packages/nocodb/src/lib/plugins/backblaze/Backblaze.ts @@ -77,7 +77,7 @@ export default class Backblaze implements IStorageAdapterV2 { // in v0.0.1, we constructed the endpoint with `region = s3.us-west-001` // in v0.0.2, `region` would be `us-west-001` // as backblaze states Region is the 2nd part of your S3 Endpoint in documentation - if (region.slice(0, 3) === 's3.') { + if (region.startsWith('s3.')) { region = region.slice(3); } return region;