From f6b36d9e95bb4d514fcd973ef6d6822c00d5bfd0 Mon Sep 17 00:00:00 2001 From: alma Date: Sat, 24 May 2025 20:59:23 +0200 Subject: [PATCH] W n8n attention vm --- components/missions/file-upload.tsx | 42 +++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/components/missions/file-upload.tsx b/components/missions/file-upload.tsx index aaef13be..bc7e6d0c 100644 --- a/components/missions/file-upload.tsx +++ b/components/missions/file-upload.tsx @@ -104,7 +104,7 @@ export function FileUpload({ return true; }; - const handleFileDrop = (e: React.DragEvent) => { + const handleFileDrop = async (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); setIsDragging(false); @@ -115,11 +115,21 @@ export function FileUpload({ setFile(droppedFile); // If this is a new mission, call onFileSelect instead of waiting for upload if (isNewMission && onFileSelect) { - onFileSelect({ - data: URL.createObjectURL(droppedFile), - name: droppedFile.name, - type: droppedFile.type - }); + try { + const base64 = await convertFileToBase64(droppedFile); + onFileSelect({ + data: base64, + name: droppedFile.name, + type: droppedFile.type + }); + } catch (error) { + console.error('Error converting file to base64:', error); + toast({ + title: 'Error', + description: 'Failed to process file. Please try again.', + variant: 'destructive', + }); + } } } } @@ -191,11 +201,21 @@ export function FileUpload({ // For new missions, just notify through the callback and don't try to upload if (isNewMission) { if (onFileSelect) { - onFileSelect({ - data: URL.createObjectURL(fileToUpload), - name: fileToUpload.name, - type: fileToUpload.type - }); + try { + const base64 = await convertFileToBase64(fileToUpload); + onFileSelect({ + data: base64, + name: fileToUpload.name, + type: fileToUpload.type + }); + } catch (error) { + console.error('Error converting file to base64:', error); + toast({ + title: 'Error', + description: 'Failed to process file. Please try again.', + variant: 'destructive', + }); + } } toast({ title: 'File selected',