mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-06 09:59:00 +02:00
✨ Enable object store for self-hosted instance (#1739)
This commit is contained in:
parent
294ab49e9f
commit
fbccc4f98b
7 changed files with 98 additions and 54 deletions
4
apps/web/src/features/storage/index.ts
Normal file
4
apps/web/src/features/storage/index.ts
Normal 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;
|
26
apps/web/src/features/storage/s3.ts
Normal file
26
apps/web/src/features/storage/s3.ts
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue