mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 21:09:37 +02:00
refactor: Update S3 configuration and endpoint handling
This commit is contained in:
parent
feed624601
commit
b660dcad08
2 changed files with 9 additions and 7 deletions
|
@ -8,12 +8,10 @@ services:
|
|||
# ORIGIN is only necessary when not using a reverse proxy or hosting that includes https
|
||||
- ORIGIN=http://localhost:3000
|
||||
- SKIP_DB_WAIT=false
|
||||
- MINIO_SERVER_URL=minio
|
||||
- MINIO_CLIENT_URL=http://localhost:9000
|
||||
- MINIO_ENDPOINT=minio
|
||||
- MINIO_ACCESS_KEY=minioadmin
|
||||
- MINIO_SECRET_KEY=minioadmin
|
||||
- MINIO_USE_SSL=false
|
||||
- AWS_ACCESS_KEY_ID=minioadmin
|
||||
- AWS_SECRET_ACCESS_KEY=minioadmin
|
||||
- AWS_S3_ENDPOINT=http://minio:9000
|
||||
- MINIO_CLIENT_OVERRIDE=http://localhost:9000
|
||||
- BODY_SIZE_LIMIT=Infinity
|
||||
# Only necessary for externally hosted databases such as NeonDB
|
||||
depends_on:
|
||||
|
|
|
@ -10,7 +10,7 @@ import { env } from "$env/dynamic/private";
|
|||
console.log(env.AWS_ACCESS_KEY_ID as string);
|
||||
|
||||
const s3Config: S3ClientConfig = {
|
||||
region: env.AWS_REGION as string,
|
||||
region: (env.AWS_REGION as string) || "us-east-1",
|
||||
credentials: {
|
||||
accessKeyId: env.AWS_ACCESS_KEY_ID as string,
|
||||
secretAccessKey: env.AWS_SECRET_ACCESS_KEY as string,
|
||||
|
@ -28,6 +28,7 @@ export const ensureBucketExists = async (bucketName: string): Promise<void> => {
|
|||
await s3Client.send(headBucketCommand);
|
||||
console.log(`Bucket ${bucketName} already exists.`);
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
if (error.$metadata.httpStatusCode === 404) {
|
||||
console.log(`Bucket ${bucketName} does not exist. Creating...`);
|
||||
const createBucketCommand = new CreateBucketCommand({
|
||||
|
@ -85,6 +86,9 @@ export const uploadObject = async (
|
|||
|
||||
// Determine the provider from the endpoint
|
||||
let endpoint = env.AWS_S3_ENDPOINT as string;
|
||||
if (env.MINIO_CLIENT_OVERRIDE) {
|
||||
endpoint = env.MINIO_CLIENT_OVERRIDE;
|
||||
}
|
||||
let objectUrl: string;
|
||||
|
||||
if (endpoint.includes("amazonaws.com")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue