From a2c233aed33aabe6a44348a3118a444814272223 Mon Sep 17 00:00:00 2001 From: Zac Gaetano Date: Tue, 7 Apr 2026 22:05:40 -0400 Subject: [PATCH] Phase 2: services/mam-api/src/s3/client.js --- services/mam-api/src/s3/client.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/mam-api/src/s3/client.js b/services/mam-api/src/s3/client.js index b197a95..aa0e506 100644 --- a/services/mam-api/src/s3/client.js +++ b/services/mam-api/src/s3/client.js @@ -2,6 +2,8 @@ import { S3Client, GetObjectCommand, DeleteObjectCommand } from '@aws-sdk/client import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; import { Upload } from '@aws-sdk/lib-storage'; +export const S3_BUCKET = process.env.S3_BUCKET || 'mam'; + const s3Client = new S3Client({ region: process.env.S3_REGION || 'us-east-1', endpoint: process.env.S3_ENDPOINT, @@ -9,6 +11,7 @@ const s3Client = new S3Client({ accessKeyId: process.env.S3_ACCESS_KEY, secretAccessKey: process.env.S3_SECRET_KEY, }, + forcePathStyle: true, }); export { s3Client }; @@ -16,7 +19,7 @@ export { s3Client }; export const getSignedUrlForObject = async (key, expiresIn = 3600) => { try { const command = new GetObjectCommand({ - Bucket: process.env.S3_BUCKET, + Bucket: S3_BUCKET, Key: key, }); const url = await getSignedUrl(s3Client, command, { expiresIn }); @@ -32,7 +35,7 @@ export const uploadStream = async (key, stream, contentType) => { const upload = new Upload({ client: s3Client, params: { - Bucket: process.env.S3_BUCKET, + Bucket: S3_BUCKET, Key: key, Body: stream, ContentType: contentType, @@ -50,7 +53,7 @@ export const uploadStream = async (key, stream, contentType) => { export const deleteObject = async (key) => { try { const command = new DeleteObjectCommand({ - Bucket: process.env.S3_BUCKET, + Bucket: S3_BUCKET, Key: key, }); const result = await s3Client.send(command);