Skip to content

Commit ca4d4ee

Browse files
committed
chore: add minio region support
Signed-off-by: CosPotato <[email protected]>
1 parent 0ed004f commit ca4d4ee

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

apps/nestjs-backend/src/configs/storage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const storageConfig = registerAs('storage', () => ({
1818
useSSL: process.env.BACKEND_STORAGE_MINIO_USE_SSL === 'true',
1919
accessKey: process.env.BACKEND_STORAGE_MINIO_ACCESS_KEY,
2020
secretKey: process.env.BACKEND_STORAGE_MINIO_SECRET_KEY,
21+
region: process.env.BACKEND_STORAGE_MINIO_REGION,
2122
},
2223
s3: {
2324
region: process.env.BACKEND_STORAGE_S3_REGION!,

apps/nestjs-backend/src/features/attachments/plugins/minio.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ export class MinioStorage implements StorageAdapter {
1717
minioClientPrivateNetwork: minio.Client;
1818

1919
constructor(@StorageConfig() readonly config: IStorageConfig) {
20-
const { endPoint, internalEndPoint, internalPort, port, useSSL, accessKey, secretKey } =
20+
const { endPoint, internalEndPoint, internalPort, port, useSSL, accessKey, secretKey, region } =
2121
this.config.minio;
2222
this.minioClient = new minio.Client({
2323
endPoint: endPoint!,
2424
port: port!,
2525
useSSL: useSSL!,
2626
accessKey: accessKey!,
2727
secretKey: secretKey!,
28+
region: region,
2829
});
2930
this.minioClientPrivateNetwork = internalEndPoint
3031
? new minio.Client({
@@ -33,6 +34,7 @@ export class MinioStorage implements StorageAdapter {
3334
useSSL: false,
3435
accessKey: accessKey!,
3536
secretKey: secretKey!,
37+
region: region,
3638
})
3739
: this.minioClient;
3840
fse.ensureDirSync(StorageAdapter.TEMPORARY_DIR);

apps/nextjs-app/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ BACKEND_STORAGE_MINIO_INTERNAL_PORT=9000
2828
BACKEND_STORAGE_MINIO_USE_SSL=true
2929
BACKEND_STORAGE_MINIO_ACCESS_KEY=access-key
3030
BACKEND_STORAGE_MINIO_SECRET_KEY=secrect-key
31+
# minio region, optional
32+
BACKEND_STORAGE_MINIO_REGION=us-east-1
3133

3234
# storage prefix, default is PUBLIC_ORIGIN, if you want to use minio storage, you need to set this value
3335
STORAGE_PREFIX=http://localhost:3000

0 commit comments

Comments
 (0)