From 5083fdc7175c8e1e22c97cef0b0f22921c7d1b37 Mon Sep 17 00:00:00 2001 From: "shiweisong.ssw" Date: Wed, 28 Jun 2023 17:46:53 +0800 Subject: [PATCH] feat: change the type of the body --- datacenter/app/datastores/documents/page.tsx | 10 +++++----- datacenter/app/datastores/page.tsx | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/datacenter/app/datastores/documents/page.tsx b/datacenter/app/datastores/documents/page.tsx index e64bcb1b5..511f848c8 100644 --- a/datacenter/app/datastores/documents/page.tsx +++ b/datacenter/app/datastores/documents/page.tsx @@ -347,6 +347,10 @@ const Documents = () => { message.error('Please select a file') return } + const formData = new FormData(); + formData.append('doc_name', documentName); + formData.append('doc_file', originFileObj); + formData.append('doc_type', 'DOCUMENT'); const res = await fetch( `http://localhost:8000/knowledge/${spaceName}/document/upload`, { @@ -354,11 +358,7 @@ const Documents = () => { headers: { 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' }, - body: JSON.stringify({ - doc_name: documentName, - doc_file: originFileObj, - doc_type: 'DOCUMENT' - }) + body: formData } ) const data = await res.json() diff --git a/datacenter/app/datastores/page.tsx b/datacenter/app/datastores/page.tsx index 69913be2d..ceea11a0a 100644 --- a/datacenter/app/datastores/page.tsx +++ b/datacenter/app/datastores/page.tsx @@ -344,6 +344,10 @@ const Index = () => { message.error('Please select a file') return } + const formData = new FormData(); + formData.append('doc_name', documentName); + formData.append('doc_file', originFileObj); + formData.append('doc_type', 'DOCUMENT'); const res = await fetch( `http://localhost:8000/knowledge/${knowledgeSpaceName}/document/upload`, { @@ -351,11 +355,7 @@ const Index = () => { headers: { 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' }, - body: JSON.stringify({ - doc_name: documentName, - doc_file: originFileObj, - doc_type: 'DOCUMENT' - }) + body: formData } ) const data = await res.json()