Browse Source

fix: gcs uniform bucket_level access

pull/9734/head
DarkPhoenix2704 4 weeks ago
parent
commit
97402c7961
  1. 11
      packages/nocodb/src/plugins/gcs/Gcs.ts
  2. 8
      packages/nocodb/src/plugins/gcs/index.ts

11
packages/nocodb/src/plugins/gcs/Gcs.ts

@ -13,6 +13,7 @@ interface GoogleCloudStorageInput {
private_key: string;
bucket: string;
project_id?: string;
uniform_bucket_level_access?: boolean;
}
export default class Gcs implements IStorageAdapterV2 {
@ -34,6 +35,12 @@ export default class Gcs implements IStorageAdapterV2 {
return patchedKey;
}
private aclConfig(): { predefinedAcl: 'publicRead' } | {} {
return this.input.uniform_bucket_level_access
? {}
: { predefinedAcl: 'publicRead' };
}
public async init(): Promise<void> {
const options: StorageOptions = {
credentials: {
@ -89,10 +96,10 @@ export default class Gcs implements IStorageAdapterV2 {
destination: this.patchKey(key),
contentType: file?.mimetype || 'application/octet-stream',
gzip: true,
predefinedAcl: 'publicRead',
metadata: {
cacheControl: 'public, max-age=31536000',
},
...this.aclConfig(),
});
return uploadResponse.publicUrl();
@ -114,11 +121,11 @@ export default class Gcs implements IStorageAdapterV2 {
.pipe(
file.createWriteStream({
gzip: true,
predefinedAcl: 'publicRead',
metadata: {
contentType: options.mimetype || 'application/octet-stream',
cacheControl: 'public, max-age=31536000',
},
...this.aclConfig(),
}),
)
.on('finish', () => resolve())

8
packages/nocodb/src/plugins/gcs/index.ts

@ -5,7 +5,7 @@ import type { XcPluginConfig } from '~/types/nc-plugin';
const config: XcPluginConfig = {
builder: GcsPlugin,
title: 'GCS',
version: '0.0.3',
version: '0.0.4',
logo: 'plugins/gcs.png',
description:
'Google Cloud Storage is a RESTful online file storage web service for storing and accessing data on Google Cloud Platform infrastructure.',
@ -43,6 +43,12 @@ const config: XcPluginConfig = {
type: XcType.SingleLineText,
required: false,
},
{
key: 'uniform_bucket_level_access',
label: 'Uniform Bucket Level Access',
type: XcType.Checkbox,
required: false,
},
],
actions: [
{

Loading…
Cancel
Save