diff --git a/package.json b/package.json index af1a5321..13b688b1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "codex.docs", "license": "Apache-2.0", - "version": "2.3.2", + "version": "2.3.3", "type": "module", "bin": { "codex.docs": "dist/backend/app.js" diff --git a/src/backend/uploads/s3.ts b/src/backend/uploads/s3.ts index 142df366..cadd06a3 100644 --- a/src/backend/uploads/s3.ts +++ b/src/backend/uploads/s3.ts @@ -6,7 +6,7 @@ import mime from 'mime'; import multer from 'multer'; import { S3UploadsConfig } from '../utils/appConfig.js'; import { FileData } from '../models/file.js'; -import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'; +import { PutObjectCommand, S3Client, S3ClientConfig } from '@aws-sdk/client-s3'; import fileType from 'file-type'; /** @@ -30,13 +30,19 @@ export default class S3UploadsDriver implements UploadsDriver { */ constructor(config: S3UploadsConfig) { this.config = config; - this.s3Client = new S3Client({ + const clientConfig: S3ClientConfig = { region: this.config.s3.region, credentials: { accessKeyId: this.config.s3.accessKeyId, secretAccessKey: this.config.s3.secretAccessKey, }, - }); + }; + + if (this.config.s3.endpoint) { + clientConfig.endpoint = this.config.s3.endpoint; + } + + this.s3Client = new S3Client(clientConfig); } /** diff --git a/src/backend/utils/appConfig.ts b/src/backend/utils/appConfig.ts index 34a5e610..6df6e8b7 100644 --- a/src/backend/utils/appConfig.ts +++ b/src/backend/utils/appConfig.ts @@ -34,6 +34,7 @@ const S3UploadsConfig = z.object({ keyPrefix: z.string(), accessKeyId: z.string(), secretAccessKey: z.string(), + endpoint: z.string().optional(), }), });