|
1 | | -import axios from 'axios'; |
2 | 1 | import { Dropzone, Flex, Typography } from '@neo4j-ndl/react'; |
3 | 2 | import React, { useState, useEffect, FunctionComponent } from 'react'; |
4 | 3 | import Loader from '../utils/Loader'; |
5 | 4 | import { v4 as uuidv4 } from 'uuid'; |
6 | 5 | import { useCredentials } from '../context/UserCredentials'; |
7 | 6 | import { useFileContext } from '../context/UsersFiles'; |
8 | 7 | import CustomAlert from './Alert'; |
9 | | -import { CustomFile, CustomFileBase, UploadResponse, alertStateType } from '../types'; |
| 8 | +import { CustomFile, CustomFileBase, UserCredentials, alertStateType } from '../types'; |
10 | 9 | import { buttonCaptions, chunkSize } from '../utils/Constants'; |
11 | | -import { url } from '../utils/Utils'; |
12 | 10 | import { InformationCircleIconOutline } from '@neo4j-ndl/react/icons'; |
13 | 11 | import IconButtonWithToolTip from './IconButtonToolTip'; |
| 12 | +import { uploadAPI } from '../utils/FileAPI'; |
14 | 13 |
|
15 | 14 | const DropZone: FunctionComponent = () => { |
16 | 15 | const { filesData, setFilesData, model } = useFileContext(); |
@@ -122,12 +121,7 @@ const DropZone: FunctionComponent = () => { |
122 | 121 | }) |
123 | 122 | ); |
124 | 123 | try { |
125 | | - const apiResponse = await axios.post<UploadResponse>(`${url()}/upload`, formData, { |
126 | | - headers: { |
127 | | - 'Content-Type': 'multipart/form-data', |
128 | | - }, |
129 | | - }); |
130 | | - |
| 124 | + const apiResponse=await uploadAPI(chunk,userCredentials as UserCredentials,model,chunkNumber,totalChunks,file.name) |
131 | 125 | if (apiResponse?.data.status === 'Failed') { |
132 | 126 | throw new Error( |
133 | 127 | JSON.stringify({ message: apiResponse.data.message, fileName: apiResponse.data.file_name }) |
@@ -283,7 +277,7 @@ const DropZone: FunctionComponent = () => { |
283 | 277 | setalertDetails({ |
284 | 278 | showAlert: true, |
285 | 279 | alertType: 'error', |
286 | | - alertMessage: 'Failed To Upload, File is larger than 15MB', |
| 280 | + alertMessage: 'Failed To Upload, Unsupported file extention', |
287 | 281 | }); |
288 | 282 | } |
289 | 283 | }, |
|
0 commit comments