diff --git a/document/content/docs/introduction/development/openapi/share.mdx b/document/content/docs/introduction/development/openapi/share.mdx index 2ab48f32f..fd6fa7a29 100644 --- a/document/content/docs/introduction/development/openapi/share.mdx +++ b/document/content/docs/introduction/development/openapi/share.mdx @@ -28,7 +28,7 @@ description: FastGPT 分享链接身份鉴权 `FastGPT` 将会判断`success`是否为`true`决定是允许用户继续操作。`message`与`msg`是等同的,你可以选择返回其中一个,当`success`不为`true`时,将会提示这个错误。 -`uid` 是用户的唯一凭证,必须返回该 ID 且 ID 的格式为不包含 "|"、"/“、"\" 字符的、长度小于等于 255 的字符串,否则会返回 `Invalid UID` 的错误。`uid` 将会用于拉取对话记录以及保存对话记录,可参考下方实践案例。 +`uid` 是用户的唯一凭证,必须返回该 ID 且 ID 的格式为不包含 "|"、"/“、"\\" 字符的、小于等于 255 **字节长度**的字符串,否则会返回 `Invalid UID` 的错误。`uid` 将会用于拉取对话记录以及保存对话记录,可参考下方实践案例。 ### 触发流程 diff --git a/document/data/doc-last-modified.json b/document/data/doc-last-modified.json index 47494be8f..69d243dfb 100644 --- a/document/data/doc-last-modified.json +++ b/document/data/doc-last-modified.json @@ -118,7 +118,7 @@ "document/content/docs/upgrading/4-14/4141.mdx": "2025-11-19T10:15:27+08:00", "document/content/docs/upgrading/4-14/4142.mdx": "2025-11-18T19:27:14+08:00", "document/content/docs/upgrading/4-14/4143.mdx": "2025-11-26T20:52:05+08:00", - "document/content/docs/upgrading/4-14/4144.mdx": "2025-12-08T21:02:38+08:00", + "document/content/docs/upgrading/4-14/4144.mdx": "2025-12-08T21:45:21+08:00", "document/content/docs/upgrading/4-8/40.mdx": "2025-08-02T19:38:37+08:00", "document/content/docs/upgrading/4-8/41.mdx": "2025-08-02T19:38:37+08:00", "document/content/docs/upgrading/4-8/42.mdx": "2025-08-02T19:38:37+08:00", diff --git a/packages/service/common/s3/constants.ts b/packages/service/common/s3/constants.ts index b9017293c..7b9b7c5bd 100644 --- a/packages/service/common/s3/constants.ts +++ b/packages/service/common/s3/constants.ts @@ -53,8 +53,4 @@ export const getSystemMaxFileSize = () => { return config; // bytes }; -export const S3_KEY_PATH_INVALID_CHARS_MAP: Record = { - '/': true, - '\\': true, - '|': true -}; +export const S3_KEY_PATH_INVALID_CHARS = /[|\\/]/; diff --git a/packages/service/common/s3/utils.ts b/packages/service/common/s3/utils.ts index cdc68b766..59bfa69d9 100644 --- a/packages/service/common/s3/utils.ts +++ b/packages/service/common/s3/utils.ts @@ -11,7 +11,6 @@ import { getNanoid } from '@fastgpt/global/common/string/tools'; import path from 'node:path'; import type { ParsedFileContentS3KeyParams } from './sources/dataset/type'; import { EndpointUrl } from '@fastgpt/global/common/file/constants'; -import type { NextApiRequest } from 'next'; // S3文件名最大长度配置 export const S3_FILENAME_MAX_LENGTH = 50; @@ -246,130 +245,3 @@ export function isS3ObjectKey( ): key is `${T}/${string}` { return typeof key === 'string' && key.startsWith(`${S3Sources[source]}/`); } - -// export const multer = { -// _storage: multer.diskStorage({ -// filename: (_, file, cb) => { -// if (!file?.originalname) { -// cb(new Error('File not found'), ''); -// } else { -// const ext = path.extname(decodeURIComponent(file.originalname)); -// cb(null, `${getNanoid()}${ext}`); -// } -// } -// }), - -// singleStore(maxFileSize: number = 500) { -// const fileSize = maxFileSize * 1024 * 1024; - -// return multer({ -// limits: { -// fileSize -// }, -// preservePath: true, -// storage: this._storage -// }).single('file'); -// }, - -// multipleStore(maxFileSize: number = 500) { -// const fileSize = maxFileSize * 1024 * 1024; - -// return multer({ -// limits: { -// fileSize -// }, -// preservePath: true, -// storage: this._storage -// }).array('file', global.feConfigs?.uploadFileMaxSize); -// }, - -// resolveFormData({ request, maxFileSize }: { request: NextApiRequest; maxFileSize?: number }) { -// return new Promise<{ -// data: Record; -// fileMetadata: Express.Multer.File; -// getBuffer: () => Buffer; -// getReadStream: () => fs.ReadStream; -// }>((resolve, reject) => { -// const handler = this.singleStore(maxFileSize); - -// // @ts-expect-error it can accept a NextApiRequest -// handler(request, null, (error) => { -// if (error) { -// return reject(error); -// } - -// // @ts-expect-error `file` will be injected by multer -// const file = request.file as Express.Multer.File; - -// if (!file) { -// return reject(new Error('File not found')); -// } - -// const data = (() => { -// if (!request.body?.data) return {}; -// try { -// return JSON.parse(request.body.data); -// } catch { -// return {}; -// } -// })(); - -// resolve({ -// data, -// fileMetadata: file, -// getBuffer: () => fs.readFileSync(file.path), -// getReadStream: () => fs.createReadStream(file.path) -// }); -// }); -// }); -// }, - -// resolveMultipleFormData({ -// request, -// maxFileSize -// }: { -// request: NextApiRequest; -// maxFileSize?: number; -// }) { -// return new Promise<{ -// data: Record; -// fileMetadata: Array; -// }>((resolve, reject) => { -// const handler = this.multipleStore(maxFileSize); - -// // @ts-expect-error it can accept a NextApiRequest -// handler(request, null, (error) => { -// if (error) { -// return reject(error); -// } - -// // @ts-expect-error `files` will be injected by multer -// const files = request.files as Array; - -// if (!files || files.length === 0) { -// return reject(new Error('File not found')); -// } - -// const data = (() => { -// if (!request.body?.data) return {}; -// try { -// return JSON.parse(request.body.data); -// } catch { -// return {}; -// } -// })(); - -// resolve({ -// data, -// fileMetadata: files -// }); -// }); -// }); -// }, - -// clearDiskTempFiles(filepaths: string[]) { -// for (const filepath of filepaths) { -// fs.unlink(filepath, (_) => {}); -// } -// } -// };