@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
32 lines (27 loc) • 691 B
text/typescript
import { dispatch } from '@lobechat/electron-client-ipc';
import { FileMetadata } from '@/types/files';
/**
* 桌面应用文件API客户端服务
*/
class DesktopFileAPI {
/**
* 上传文件到桌面应用
* @param file 文件对象
* @param hash 文件哈希
* @returns 上传结果
*/
async uploadFile(
file: File,
hash: string,
): Promise<{ metadata: FileMetadata; success: boolean }> {
const arrayBuffer = await file.arrayBuffer();
return dispatch('createFile', {
content: arrayBuffer,
filename: file.name,
hash,
path: file.name,
type: file.type,
});
}
}
export const desktopFileAPI = new DesktopFileAPI();