How to transfer MultipartFile and File in java
This article mainly shows you "how to convert MultipartFile and File in java". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to convert MultipartFile and File in java".
MultipartFile to File
The company's business needs to receive pictures or documents (multipart/form-data) submitted by the front desk (ps: I don't know if it's misspelled hee hee)
Received in the background needs to be converted to a File type
So here is the issue of type conversion:
List my code first:
@ PostMapping ("upload") @ ResponseBody public void upload (HttpServletResponse response,MultipartFile file) throws IOException {/ / MultipartFile file = ((MultipartHttpServletRequest) request) .getFile ("file"); PrintWriter writer = response.getWriter (); File f = null; if (file.equals (") | file.getSize ()