feat(Uploader): add file result-type (#4680)

This commit is contained in:
neverland
2019-10-10 20:09:22 +08:00
committed by GitHub
parent 1d9b3e2013
commit 1044179354
5 changed files with 60 additions and 9 deletions

View File

@@ -1,3 +1,5 @@
export type ResultType = 'dataUrl' | 'text' | 'file';
export function toArray<T>(item: T | T[]): T[] {
if (Array.isArray(item)) {
return item;
@@ -6,8 +8,13 @@ export function toArray<T>(item: T | T[]): T[] {
return [item];
}
export function readFile(file: File, resultType: string) {
export function readFile(file: File, resultType: ResultType) {
return new Promise(resolve => {
if (resultType === 'file') {
resolve();
return;
}
const reader = new FileReader();
reader.onload = event => {