mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-31 03:22:18 +00:00
4.6.7 first pr (#726)
This commit is contained in:
22
packages/web/common/file/read/rawText.ts
Normal file
22
packages/web/common/file/read/rawText.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* read file raw text
|
||||
*/
|
||||
export const readFileRawText = (file: File) => {
|
||||
return new Promise<{ rawText: string }>((resolve, reject) => {
|
||||
try {
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
resolve({
|
||||
rawText: reader.result as string
|
||||
});
|
||||
};
|
||||
reader.onerror = (err) => {
|
||||
console.log('error txt read:', err);
|
||||
reject('Read file error');
|
||||
};
|
||||
reader.readAsText(file);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user