export async function convertToFileObjects(fileData) {
// 用来存储所有 File 对象的数组
const fileArray: File[] = [];
// 使用 Promise.all 来并行下载所有文件
await Promise.all(
fileData.map(async (file) => {
try {
const response = await fetch(file.fileUrl);
if (!response.ok) {
throw new Error('文件下载失败');
}
const blob = await response.blob();
// 创建 File 对象
const fileObj = new File([blob], file.fileName, { type: file.fileType });
// 将文件对象添加到 fileArray
fileArray.push(fileObj);
} catch (error) {
console.error(`下载文件失败: ${file.fileName}`, error);
}
}),
);
return fileArray;
}