I have the following java code in Spring framework to convert a multipart file to a regular file:
public static File convertToFile(MultipartFile multipart) {
I figured out what I was doing wrong.
I was trying to convert MultipartFile to File outside of the service layer (in another component). Now I do this conversion inside the service layer (but in a separate class) and it's working fine.
MultipartFile
File