mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-11 17:27:31 +02:00
Update file upload handling to use native Node.js FormData
Migrate from the 'form-data' npm package to Node.js's built-in 'node:buffer' module for FormData, File, and Blob to resolve dynamic require errors and improve compatibility with newer Node.js versions. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: fb46322f-df17-46db-ba41-3f694e6331a9 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/LXHtbOp
This commit is contained in:
1 parent
e9827c333d
commit
fb6c06d150
1 file changed
+7
-7
+7
-7
@@ -128,7 +128,6 @@ import { invoiceVerificationService } from "./invoiceVerification";
|
||||
import { backupService } from "./backupService";
|
||||
import { weatherService } from "./weatherService.js";
|
||||
import fetch from "node-fetch";
|
||||
import FormData from "form-data";
|
||||
|
||||
export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Detect environment
|
||||
@@ -820,7 +819,8 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
fieldsCount: Object.keys(formDataFields).length
|
||||
});
|
||||
|
||||
// Préparer le FormData pour l'envoi au webhook externe
|
||||
// Utiliser le FormData natif de Node.js (disponible depuis Node 18+)
|
||||
const { FormData, File, Blob } = await import('node:buffer');
|
||||
const formData = new FormData();
|
||||
|
||||
// Ajouter tous les champs du formData
|
||||
@@ -829,10 +829,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Reconstituer le fichier depuis base64
|
||||
const fileData = value as { base64: string; filename: string; contentType: string };
|
||||
const buffer = Buffer.from(fileData.base64, 'base64');
|
||||
formData.append('file', buffer, {
|
||||
filename: fileData.filename,
|
||||
contentType: fileData.contentType
|
||||
});
|
||||
|
||||
// Créer un Blob/File natif Node.js
|
||||
const blob = new Blob([buffer], { type: fileData.contentType });
|
||||
const file = new File([blob], fileData.filename, { type: fileData.contentType });
|
||||
formData.append('file', file);
|
||||
} else {
|
||||
formData.append(key, value as string);
|
||||
}
|
||||
@@ -844,7 +845,6 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
const response = await fetch(webhookUrl, {
|
||||
method: 'POST',
|
||||
body: formData as any,
|
||||
headers: formData.getHeaders(),
|
||||
signal: controller.signal
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user