From bc9c9550525841b8baede92e8515e95c94ec0efb Mon Sep 17 00:00:00 2001 From: AishDani Date: Wed, 19 Jun 2024 13:51:13 +0530 Subject: [PATCH] refactor:modified validated api props --- .../components/LegacyCms/Actions/LoadUploadFile.tsx | 2 +- ui/src/services/api/upload.service.ts | 12 ++++++++++-- uplaode-api/src/routes/index.ts | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx index 314ec21e..b1c2f1fe 100644 --- a/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx +++ b/ui/src/components/LegacyCms/Actions/LoadUploadFile.tsx @@ -76,7 +76,7 @@ const LoadUploadFile = (props: LoadUploadFileProps) => { setProgressPercentage(30); setShowProgress(true); - const res: any = await fileValidation(); + const res: any = await fileValidation(projectId); if(res?.status === 200){ setIsValidated(true); setValidationMessage('Validated'); diff --git a/ui/src/services/api/upload.service.ts b/ui/src/services/api/upload.service.ts index 67ada600..ead7f3f2 100644 --- a/ui/src/services/api/upload.service.ts +++ b/ui/src/services/api/upload.service.ts @@ -2,6 +2,7 @@ import axios from 'axios'; import { UPLOAD_FILE_RELATIVE_URL } from '../../utilities/constants'; import { User, SmsToken } from '../../pages/Login/login.interface'; import { API_VERSION } from '../../utilities/constants'; +import { getDataFromLocalStorage } from '../../utilities/functions'; //Axios Calls for Upload server export const getCall = async (url: string, options?: any) => { @@ -36,9 +37,16 @@ export const uploadFilePath = () => { return `${UPLOAD_FILE_RELATIVE_URL}upload`; }; -export const fileValidation = () => { +export const fileValidation = (projectId: string) => { try { - return getCall(`${UPLOAD_FILE_RELATIVE_URL}validator`); + const options = { + headers: { + 'app_token': getDataFromLocalStorage('app_token'), + 'projectId': projectId + }, + + }; + return getCall(`${UPLOAD_FILE_RELATIVE_URL}validator`, options); } catch (error) { return error; } diff --git a/uplaode-api/src/routes/index.ts b/uplaode-api/src/routes/index.ts index 32a46b61..b66241db 100644 --- a/uplaode-api/src/routes/index.ts +++ b/uplaode-api/src/routes/index.ts @@ -91,7 +91,7 @@ router.post('/upload', upload.single('file'), async function (req: Request, res: // deepcode ignore NoRateLimitingForExpensiveWebOperation: router.get('/validator', express.json(), fileOperationLimiter, async function (req: Request, res: Response) { try { - const projectId: string | string[] = req?.body?.projectId ?? ""; + const projectId: string | string[] = req?.headers?.projectid ?? ""; const app_token: string | string[] = req?.headers?.app_token ?? ""; const cmsType = config?.cmsType?.toLowerCase();