diff --git a/java/FileUploadController.java b/java/FileUploadController.java new file mode 100644 index 0000000..6617164 --- /dev/null +++ b/java/FileUploadController.java @@ -0,0 +1,28 @@ +import java.util.Iterator; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +@Controller +public class FileUploadController { + + @RequestMapping(value="/upload", method=RequestMethod.POST) + public String handleFileUpload(MultipartHttpServletRequest request){ + Iterator iterator = request.getFileNames(); + + while (iterator.hasNext()) { + String fileName = iterator.next(); + MultipartFile multipartFile = request.getFile(fileName); + byte[] file = multipartFile.getBytes(); + + // do stuff... + + } + + // do stuff... + + } +} \ No newline at end of file