( documentCollectionId: Id<DocumentCollectionCreateRequest>, file: File, indexingMode: IndexingMode, )
| 62 | } |
| 63 | |
| 64 | const uploadDocument = async ( |
| 65 | documentCollectionId: Id<DocumentCollectionCreateRequest>, |
| 66 | file: File, |
| 67 | indexingMode: IndexingMode, |
| 68 | ): Promise<DocumentResponse> => { |
| 69 | const formData = new FormData(); |
| 70 | formData.append("file", file); |
| 71 | formData.append("indexingMode", indexingMode); |
| 72 | |
| 73 | const res = await fetch( |
| 74 | uploadDocumentApiPath(documentCollectionId), |
| 75 | { |
| 76 | method: "POST", |
| 77 | body: formData, |
| 78 | }, |
| 79 | ); |
| 80 | |
| 81 | if (!res.ok) { |
| 82 | throw new FetchError( |
| 83 | "An error occurred while fetching the data.", |
| 84 | res.status, |
| 85 | await res.json(), |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | return await res.json(); |
| 90 | }; |
no test coverage detected