Update webhook integration to use JSON for sending PDF data

Replaces multipart form data handling with JSON payload for the webhook API call, sending PDF content as a base64 encoded string. This change also removes the `busboy` dependency.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: cfbfe47c-0c9a-4ebf-8a41-2937407eccff
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/cfbfe47c-0c9a-4ebf-8a41-2937407eccff/WbfLPZt
This commit is contained in:
michaelschal committed 2025-09-03 09:41:06 +00:00
1 parent caee73e16b
commit bd6b25e608
6 files changed
+235 -89

No files matched your search

+22 -4
View File
@@ -102,9 +102,24 @@ export default function Sidebar() {
startProcessingTimer();
try {
const formData = new FormData();
formData.append('pdf', selectedFile);
formData.append('recipient', selectedRecipient);
// Convertir le fichier en base64
const pdfBase64 = await new Promise<string>((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
const result = reader.result as string;
// Enlever le préfixe "data:application/pdf;base64,"
const base64 = result.split(',')[1];
resolve(base64);
};
reader.onerror = () => reject(new Error('Erreur lors de la lecture du fichier'));
reader.readAsDataURL(selectedFile);
});
const requestBody = {
pdfBase64,
fileName: selectedFile.name,
recipient: selectedRecipient
};
// Créer un AbortController pour gérer le timeout
const controller = new AbortController();
@@ -112,7 +127,10 @@ export default function Sidebar() {
const response = await fetch('/api/bap/send-webhook', {
method: 'POST',
body: formData,
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
signal: controller.signal,
credentials: 'include'
});