Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"comlink": "^4.4.2",
"date-fns": "^4.1.0",
"express": "^5.1.0",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.6",
"json5": "^2.2.3",
"minio": "^8.0.5",
"nanoid": "^5.1.5",
Expand Down Expand Up @@ -429,7 +431,7 @@
},
"sdk": {
"name": "@fastgpt-sdk/plugin",
"version": "0.1.3",
"version": "0.1.7",
"dependencies": {
"@fortaine/fetch-event-source": "^3.0.6",
"@ts-rest/core": "^3.52.1",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"comlink": "^4.4.2",
"date-fns": "^4.1.0",
"express": "^5.1.0",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.6",
"json5": "^2.2.3",
"minio": "^8.0.5",
"nanoid": "^5.1.5",
Expand Down Expand Up @@ -73,4 +75,4 @@
"npm run prettier"
]
}
}
}
14 changes: 13 additions & 1 deletion src/s3/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { z } from 'zod';
import { S3Service } from './controller';
import { HttpsProxyAgent } from 'https-proxy-agent';
import { HttpProxyAgent } from 'http-proxy-agent';

export type FileConfig = {
maxFileSize: number; // 文件大小限制(字节)
Expand All @@ -10,8 +12,17 @@ export type FileConfig = {
accessKey: string; // MinIO access key
secretKey: string; // MinIO secret key
bucket: string; // 存储桶名称
transportAgent: any; // 代理
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no any

};

let transportAgent;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const transportAgent = process.env.MINIO_USE_SSL === 'true'
? new HttpsProxyAgent(process.env.HTTP_PROXY)
: new HttpProxyAgent(process.env.HTTP_PROXY);
}

if (process.env.HTTP_PROXY) {
transportAgent =
process.env.MINIO_USE_SSL === 'true'
? new HttpsProxyAgent(process.env.HTTP_PROXY)
: new HttpProxyAgent(process.env.HTTP_PROXY);
}

// 默认配置(动态从环境变量读取)
export const defaultFileConfig: FileConfig = {
maxFileSize: process.env.MAX_FILE_SIZE ? parseInt(process.env.MAX_FILE_SIZE) : 20 * 1024 * 1024, // 默认 20MB
Expand All @@ -21,7 +32,8 @@ export const defaultFileConfig: FileConfig = {
useSSL: process.env.MINIO_USE_SSL === 'true',
accessKey: process.env.MINIO_ACCESS_KEY || 'minioadmin',
secretKey: process.env.MINIO_SECRET_KEY || 'minioadmin',
bucket: process.env.MINIO_BUCKET || 'files'
bucket: process.env.MINIO_BUCKET || 'files',
transportAgent: transportAgent
};

export const FileMetadataSchema = z.object({
Expand Down
3 changes: 2 additions & 1 deletion src/s3/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export class S3Service {
port: this.config.port,
useSSL: this.config.useSSL,
accessKey: this.config.accessKey,
secretKey: this.config.secretKey
secretKey: this.config.secretKey,
transportAgent: this.config.transportAgent
});
}

Expand Down