0

I am using HtmlUnit to upload a file by making a request to the spring controller. The file is of type MultipartFile. Using the below code works only for File Type java.io.File. How do i make the call for MultipartFile?

WebRequest request = new WebRequest(new URL("/customer/uploadfile),POST);

request.setRequestParameters(toList(new KeyDataPair("newfile", file,"customerfile", "multipart/form-data", StandardCharsets.UTF_8)));

James Franco
  • 53
  • 3
  • 10
  • Show your controller code. You can transform MultipartFile to File and then issue the call. – NikolaB Sep 07 '20 at 19:17
  • public ModelAndView uploadCustomerFile(ModelMap model, RedirectAttributes redirect, @ModelAttribute MultipartFile file, ) { } I can't change the multipartfile to file. The method should have Multipartfile. – James Franco Sep 07 '20 at 21:45

0 Answers0