Enable object store for self-hosted instance (#1739)

This commit is contained in:
Luke Vella 2025-05-28 17:33:41 +01:00
parent 294ab49e9f
commit fbccc4f98b
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C
7 changed files with 98 additions and 54 deletions

View file

@ -0,0 +1,4 @@
export const isStorageEnabled =
!!process.env.S3_BUCKET_NAME &&
!!process.env.S3_ACCESS_KEY_ID &&
!!process.env.S3_SECRET_ACCESS_KEY;

View file

@ -0,0 +1,26 @@
import { S3Client } from "@aws-sdk/client-s3";
import { env } from "@/env";
export function getS3Client() {
if (
!env.S3_BUCKET_NAME ||
!env.S3_ACCESS_KEY_ID ||
!env.S3_SECRET_ACCESS_KEY
) {
return null;
}
const s3Client = new S3Client({
region: env.S3_REGION,
endpoint: env.S3_ENDPOINT,
credentials: {
accessKeyId: env.S3_ACCESS_KEY_ID,
secretAccessKey: env.S3_SECRET_ACCESS_KEY,
},
// S3 compatible storage requires path style
forcePathStyle: true,
});
return s3Client;
}