mirror of https://github.com/fantasticit/think.git
fix: do't transform big file to base64
parent
2b224b1246
commit
9fe447f88b
|
@ -1,7 +1,12 @@
|
|||
import { string } from 'lib0';
|
||||
import { HttpClient } from './HttpClient';
|
||||
|
||||
const ONE_MB = 1 * 1024 * 1024;
|
||||
|
||||
export const readFileAsDataURL = (file): Promise<string | ArrayBuffer> => {
|
||||
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 });
|
||||
|
|
Loading…
Reference in New Issue