chore: 后端方法注释

This commit is contained in:
CrescentLeaf
2026-01-17 00:59:11 +08:00
parent d35ce7a255
commit 200f5fd0aa
7 changed files with 97 additions and 3 deletions

View File

@@ -36,6 +36,9 @@ class File {
getName() {
return this.bean.name
}
/**
* 获取文件的相对路径
*/
getFilePath() {
const hash = this.bean.hash
return path.join(
@@ -90,6 +93,12 @@ export default class FileManager {
return db
}
/**
* 上传文件 (与 HTTP API 对接)
* @param fileName 文件名
* @param data 文件二进制数据
* @param chatId 所属的对话
*/
static async uploadFile(fileName: string, data: Buffer, chatId?: string) {
const hash = crypto.createHash('sha256').update(data).digest('hex')
const file = FileManager.findByHash(hash)