Fix upload progress for datasets in the ui

This commit is contained in:
Jaret Burkett committed 2025-07-26 09:07:30 -06:00
1 parent 523c159579
commit 3e14a674ac
1 file changed
+7 -5
+7 -5
View File
@@ -22,8 +22,11 @@ export async function POST(request: NextRequest) {
const uploadDir = join(datasetsPath, datasetName); const uploadDir = join(datasetsPath, datasetName);
await mkdir(uploadDir, { recursive: true }); await mkdir(uploadDir, { recursive: true });
const savedFiles = await Promise.all( const savedFiles: string[] = [];
files.map(async (file: any) => {
// Process files sequentially to avoid overwhelming the system
for (let i = 0; i < files.length; i++) {
const file = files[i] as any;
const bytes = await file.arrayBuffer(); const bytes = await file.arrayBuffer();
const buffer = Buffer.from(bytes); const buffer = Buffer.from(bytes);
@@ -32,9 +35,8 @@ export async function POST(request: NextRequest) {
const filePath = join(uploadDir, fileName); const filePath = join(uploadDir, fileName);
await writeFile(filePath, buffer); await writeFile(filePath, buffer);
return fileName; savedFiles.push(fileName);
}), }
);
return NextResponse.json({ return NextResponse.json({
message: 'Files uploaded successfully', message: 'Files uploaded successfully',