Home > Enterprise >  What happens to the uploaded file if it is not processed and saved on the server?
What happens to the uploaded file if it is not processed and saved on the server?

Time:09-27

I have a controller that accepts files.

    @Controller
    public class UploadImageItem {


        @ResponseBody
        @PostMapping(value = "/uploadFile", consumes = "multipart/form-data")
        public ModelAndView uploadImagesPost(@RequestParam(value = "file", required = false) MultipartFile multipartFiles) {

            return new ModelAndView("/uploadFile");

        }


    }

Please tell me, if I did not process the received file and did not save it to the desired location, then what happens to the file, where does it go?

I'm worried that this file remains somewhere on the server and takes up space and needs to be deleted.

CodePudding user response:

From MultipartFile documentation:

The file contents are either stored in memory or temporarily on disk. In either case, the user is responsible for copying file contents to a session-level or persistent store as and if desired. The temporary storage will be cleared at the end of request processing.

You don't have to worry.

  •  Tags:  
  • java
  • Related