Skip to content

Commit 557ca22

Browse files
committed
fix (storage): Remove bucket from getS3Storage return body, rename ambiguous env vars to standardized storage config names
1 parent 59e8676 commit 557ca22

2 files changed

Lines changed: 13 additions & 18 deletions

File tree

packages/common/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const {
9494
} = require("./utils/project.helpers");
9595
const QueryEngine = require("./utils/queryEngine");
9696
const { registry, storageRegistry } = require("./utils/registry");
97-
const { getStorage, getPresignedUploadUrl, verifyUploadedFile } = require("./utils/storage.manager");
97+
const { getStorage, getPresignedUploadUrl, verifyUploadedFile, getS3CompatibleStorage } = require("./utils/storage.manager");
9898
const validateEnv = require("./utils/validateEnv");
9999
const { validateData, validateUpdateData } = require("./utils/validateData");
100100
const sessionManager = require("./utils/session.manager");
@@ -199,4 +199,5 @@ module.exports = {
199199
checkLockout,
200200
recordFailedAttempt,
201201
clearLockout,
202+
getS3CompatibleStorage
202203
};

packages/common/src/utils/storage.manager.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,9 @@ async function getS3CompatibleStorage(project) {
276276
if (!project.resources?.storage?.isExternal) {
277277

278278
if (
279-
!process.env.SUPABASE_S3_ENDPOINT ||
280-
!process.env.SUPABASE_S3_ACCESS_KEY_ID ||
281-
!process.env.SUPABASE_S3_SECRET_ACCESS_KEY ||
282-
!process.env.SUPABASE_BUCKET
279+
!process.env.SUPABASE_URL ||
280+
!process.env.SUPABASE_PUBLIC_KEY ||
281+
!process.env.SUPABASE_SECRET_KEY
283282
) {
284283
throw new Error(
285284
"Internal Supabase S3 configuration is incomplete"
@@ -288,18 +287,17 @@ async function getS3CompatibleStorage(project) {
288287

289288
const s3Client = new S3Client({
290289
region: "auto",
291-
endpoint: process.env.SUPABASE_S3_ENDPOINT,
290+
endpoint: process.env.SUPABASE_URL,
292291
forcePathStyle: true,
293292
credentials: {
294-
accessKeyId: process.env.SUPABASE_S3_ACCESS_KEY_ID,
295-
secretAccessKey: process.env.SUPABASE_S3_SECRET_ACCESS_KEY
293+
accessKeyId: process.env.SUPABASE_PUBLIC_KEY,
294+
secretAccessKey: process.env.SUPABASE_SECRET_KEY
296295
}
297296
});
298297

299298
return {
300299
provider: "supabase_internal",
301-
s3Client,
302-
bucket: process.env.SUPABASE_BUCKET
300+
s3Client
303301
};
304302
}
305303

@@ -322,8 +320,7 @@ async function getS3CompatibleStorage(project) {
322320
if (
323321
!config.s3Endpoint ||
324322
!config.s3AccessKeyId ||
325-
!config.s3SecretAccessKey ||
326-
!config.bucket
323+
!config.s3SecretAccessKey
327324
) {
328325
throw new Error(
329326
"Supabase S3-compatible configuration is incomplete"
@@ -342,8 +339,7 @@ async function getS3CompatibleStorage(project) {
342339

343340
return {
344341
provider,
345-
s3Client,
346-
bucket: config.bucket
342+
s3Client
347343
};
348344
}
349345

@@ -353,8 +349,7 @@ async function getS3CompatibleStorage(project) {
353349
if (
354350
!config.endpoint ||
355351
!config.accessKeyId ||
356-
!config.secretAccessKey ||
357-
!config.bucket
352+
!config.secretAccessKey
358353
) {
359354
throw new Error(
360355
"S3-compatible storage configuration is incomplete"
@@ -373,8 +368,7 @@ async function getS3CompatibleStorage(project) {
373368

374369
return {
375370
provider,
376-
s3Client,
377-
bucket: config.bucket
371+
s3Client
378372
};
379373
}
380374

0 commit comments

Comments
 (0)