feat: change the type of the body

This commit is contained in:
shiweisong.ssw 2023-06-28 17:46:53 +08:00
parent 856274ea74
commit 7cef8b1bc2
2 changed files with 10 additions and 10 deletions

View File

@ -347,6 +347,10 @@ const Documents = () => {
message.error('Please select a file') message.error('Please select a file')
return return
} }
const formData = new FormData();
formData.append('doc_name', documentName);
formData.append('doc_file', originFileObj);
formData.append('doc_type', 'DOCUMENT');
const res = await fetch( const res = await fetch(
`http://localhost:8000/knowledge/${spaceName}/document/upload`, `http://localhost:8000/knowledge/${spaceName}/document/upload`,
{ {
@ -354,11 +358,7 @@ const Documents = () => {
headers: { headers: {
'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
}, },
body: JSON.stringify({ body: formData
doc_name: documentName,
doc_file: originFileObj,
doc_type: 'DOCUMENT'
})
} }
) )
const data = await res.json() const data = await res.json()

View File

@ -344,6 +344,10 @@ const Index = () => {
message.error('Please select a file') message.error('Please select a file')
return return
} }
const formData = new FormData();
formData.append('doc_name', documentName);
formData.append('doc_file', originFileObj);
formData.append('doc_type', 'DOCUMENT');
const res = await fetch( const res = await fetch(
`http://localhost:8000/knowledge/${knowledgeSpaceName}/document/upload`, `http://localhost:8000/knowledge/${knowledgeSpaceName}/document/upload`,
{ {
@ -351,11 +355,7 @@ const Index = () => {
headers: { headers: {
'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' 'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
}, },
body: JSON.stringify({ body: formData
doc_name: documentName,
doc_file: originFileObj,
doc_type: 'DOCUMENT'
})
} }
) )
const data = await res.json() const data = await res.json()