Get the App
SLTechnology News&Howtos  ›  Development  › 

How to transfer MultipartFile and File in java

Shulou Source: shulou.com Published: 2022-06-03 00:44:06 11月07日 Update

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 ()

Tags: Characters files questions content that is articles types hee code strings root directory learning help business practices company foreground function background picture Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info Shulou Information NVidia Xiaomi