0

I have the following endpoint that can successfully receive files when a POST request is sent to it:

@RequestMapping(
            value="/fileUpload",
            method=RequestMethod.POST)
    public String receiveFile(@RequestParam("file") MultipartFile file) {
        return "Successfully uploaded " + file.getOriginalFilename();
    }

How can I edit the endpoint such that it can receive specifically gzip files? Is there a GzipFile class that I can replace my MultipartFile parameter with?

Vismark Juarez
  • 613
  • 4
  • 14
  • 21
  • i don't think there is any Gzip specific class for multipart file upload. But you can extend CommonsMultipartResolver and override parseRequest method to check for file extension and throw an error if not a gzip file, but the easiest way is to add validation in your controller. – Raghvendra Garg Mar 20 '19 at 06:53

1 Answers1

1

Have a look at this thread

How to decode Gzip compressed request body in Spring MVC

Essentially, you get a ServletFilter to do this work and handover extracted content to Spring through Servlet.

Gro
  • 1,613
  • 1
  • 13
  • 19