diff --git a/packages/client/src/services/file.ts b/packages/client/src/services/file.ts index 26b9a251..028a4a7a 100644 --- a/packages/client/src/services/file.ts +++ b/packages/client/src/services/file.ts @@ -1,7 +1,12 @@ -import { string } from 'lib0'; import { HttpClient } from './HttpClient'; +const ONE_MB = 1 * 1024 * 1024; + export const readFileAsDataURL = (file): Promise => { + if (file.size > ONE_MB) { + return Promise.reject(new Error('文件过大,请实现文件上传到存储服务!')); + } + return new Promise((resolve) => { const reader = new FileReader(); reader.addEventListener('load', (e) => resolve(e.target.result), { once: true });