@PostMapping("/upload") @Authenticated public CustomApiResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam("data") String jsonData, @RequestHeader("Authorization") String accessToken) { CustomApiResult customApiResult=new CustomApiResult(); //@RequestParam("Authorization") String accessToken try { // Handle file upload String path= environment.getProperty("dbBackuptFileSavePath"); String filePath= Constants.EMPTY_STRING; log.info("dbBackuptFileSavePath ::: "+path); if(path!=null && !path.equalsIgnoreCase("")){ File convertedFile = new File(path + file.getOriginalFilename()); FileOutputStream fileOutputStream = new FileOutputStream(convertedFile); fileOutputStream.write(file.getBytes()); fileOutputStream.close(); log.info("File uploaded successfully "+ file.getOriginalFilename() ); filePath= convertedFile.getPath(); } // Handle JSON data if(filePath!=null && !filePath.equalsIgnoreCase("")) { log.info(" data: " + jsonData); if(jsonData!=null) { JSONParser parser = new JSONParser(); JSONObject json = (JSONObject) parser.parse(jsonData); if(json!=null) { log.info("json :::: "+ json); log.info("filePath :::: "+ filePath); //code to insert data in table } } } JSONObject object=new JSONObject(); LocalDateTime date=LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss"); String formattedDate = date.format(formatter); object.put("submission_date",formattedDate); customApiResult.setData(object); customApiResult.setSuccess(true); customApiResult.setMessage("DB Backup Sent Successfully!!"); return customApiResult; } catch (IOException e) { JSONObject object=new JSONObject(); customApiResult.setData(object); customApiResult.setSuccess(false); customApiResult.setMessage("Unable to upload DB Backup, kindly try again later."); return customApiResult; } catch (ParseException e) { throw new RuntimeException(e); } }