4.6.7 fix (#752)

This commit is contained in:
Archer
2024-01-19 20:16:08 +08:00
committed by GitHub
parent c031e6dcc9
commit 5e2adb22f0
37 changed files with 420 additions and 293 deletions

View File

@@ -32,13 +32,24 @@ export const uploadFiles = ({
});
};
export const getUploadBase64ImgController = (props: CompressImgProps & UploadImgProps) =>
compressBase64ImgAndUpload({
maxW: 4000,
maxH: 4000,
maxSize: 1024 * 1024 * 5,
...props
});
export const getUploadBase64ImgController = (
props: CompressImgProps & UploadImgProps,
retry = 3
): Promise<string> => {
try {
return compressBase64ImgAndUpload({
maxW: 4000,
maxH: 4000,
maxSize: 1024 * 1024 * 5,
...props
});
} catch (error) {
if (retry > 0) {
return getUploadBase64ImgController(props, retry - 1);
}
return Promise.reject(error);
}
};
/**
* compress image. response base64

View File

@@ -1,29 +1,3 @@
import Papa from 'papaparse';
import { readFileRawText } from '@fastgpt/web/common/file/read/rawText';
/**
* read csv to json
* @response {
* header: string[],
* data: string[][]
* }
*/
export const readCsvContent = async (file: File) => {
try {
const { rawText: textArr } = await readFileRawText(file);
const csvArr = Papa.parse(textArr).data as string[][];
if (csvArr.length === 0) {
throw new Error('csv 解析失败');
}
return {
header: csvArr.shift() as string[],
data: csvArr.map((item) => item)
};
} catch (error) {
return Promise.reject('解析 csv 文件失败');
}
};
/**
* file download by text
*/