feat: upload PDF file on save via multipart FormData
Switch save endpoint from JSON to multipart upload so the PDF file is sent alongside extracted data and tags. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -250,17 +250,17 @@ async function handleTaggingSave(depensesTags, shouldOverwrite) {
|
|||||||
saveMessage.value = null
|
saveMessage.value = null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/save', {
|
const formData = new FormData()
|
||||||
|
formData.append('pdf_file', pdfFile.value)
|
||||||
|
formData.append('data', JSON.stringify(extractedData.value.data))
|
||||||
|
if (depensesTags && depensesTags.length > 0) {
|
||||||
|
formData.append('depenses_tags', JSON.stringify(depensesTags))
|
||||||
|
}
|
||||||
|
formData.append('overwrite', shouldOverwrite ? 'true' : 'false')
|
||||||
|
|
||||||
|
const response = await fetch('/api/save-with-pdf', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
body: formData
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
source_file: extractedData.value.source_file,
|
|
||||||
data: extractedData.value.data,
|
|
||||||
depenses_tags: depensesTags,
|
|
||||||
overwrite: shouldOverwrite || false
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = await response.json()
|
const result = await response.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user