mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-20 05:19:38 +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 is only necessary when not using a reverse proxy or hosting that includes https
|
||||||
- ORIGIN=http://localhost:3000
|
- ORIGIN=http://localhost:3000
|
||||||
- SKIP_DB_WAIT=false
|
- SKIP_DB_WAIT=false
|
||||||
- MINIO_SERVER_URL=minio
|
- AWS_ACCESS_KEY_ID=minioadmin
|
||||||
- MINIO_CLIENT_URL=http://localhost:9000
|
- AWS_SECRET_ACCESS_KEY=minioadmin
|
||||||
- MINIO_ENDPOINT=minio
|
- AWS_S3_ENDPOINT=http://minio:9000
|
||||||
- MINIO_ACCESS_KEY=minioadmin
|
- MINIO_CLIENT_OVERRIDE=http://localhost:9000
|
||||||
- MINIO_SECRET_KEY=minioadmin
|
|
||||||
- MINIO_USE_SSL=false
|
|
||||||
- BODY_SIZE_LIMIT=Infinity
|
- BODY_SIZE_LIMIT=Infinity
|
||||||
# Only necessary for externally hosted databases such as NeonDB
|
# Only necessary for externally hosted databases such as NeonDB
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { env } from "$env/dynamic/private";
|
||||||
console.log(env.AWS_ACCESS_KEY_ID as string);
|
console.log(env.AWS_ACCESS_KEY_ID as string);
|
||||||
|
|
||||||
const s3Config: S3ClientConfig = {
|
const s3Config: S3ClientConfig = {
|
||||||
region: env.AWS_REGION as string,
|
region: (env.AWS_REGION as string) || "us-east-1",
|
||||||
credentials: {
|
credentials: {
|
||||||
accessKeyId: env.AWS_ACCESS_KEY_ID as string,
|
accessKeyId: env.AWS_ACCESS_KEY_ID as string,
|
||||||
secretAccessKey: env.AWS_SECRET_ACCESS_KEY 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);
|
await s3Client.send(headBucketCommand);
|
||||||
console.log(`Bucket ${bucketName} already exists.`);
|
console.log(`Bucket ${bucketName} already exists.`);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
console.log(error);
|
||||||
if (error.$metadata.httpStatusCode === 404) {
|
if (error.$metadata.httpStatusCode === 404) {
|
||||||
console.log(`Bucket ${bucketName} does not exist. Creating...`);
|
console.log(`Bucket ${bucketName} does not exist. Creating...`);
|
||||||
const createBucketCommand = new CreateBucketCommand({
|
const createBucketCommand = new CreateBucketCommand({
|
||||||
|
@ -85,6 +86,9 @@ export const uploadObject = async (
|
||||||
|
|
||||||
// Determine the provider from the endpoint
|
// Determine the provider from the endpoint
|
||||||
let endpoint = env.AWS_S3_ENDPOINT as string;
|
let endpoint = env.AWS_S3_ENDPOINT as string;
|
||||||
|
if (env.MINIO_CLIENT_OVERRIDE) {
|
||||||
|
endpoint = env.MINIO_CLIENT_OVERRIDE;
|
||||||
|
}
|
||||||
let objectUrl: string;
|
let objectUrl: string;
|
||||||
|
|
||||||
if (endpoint.includes("amazonaws.com")) {
|
if (endpoint.includes("amazonaws.com")) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue