W n8n attention vm

This commit is contained in:
alma 2025-05-24 20:59:23 +02:00
parent 9673612e92
commit f6b36d9e95

View File

@ -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) {
try {
const base64 = await convertFileToBase64(droppedFile);
onFileSelect({
data: URL.createObjectURL(droppedFile),
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) {
try {
const base64 = await convertFileToBase64(fileToUpload);
onFileSelect({
data: URL.createObjectURL(fileToUpload),
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',