<dependency>
<groupId>top.huangliusong2019</groupId>
<artifactId>filesecurity-spring-boot-starter</artifactId>
<version>1.1.3-SNAPSHOT</version>
</dependency>
filesecurity-spring-boot-starter has been uploaded to maven repository. Add the dependencies above, and you can successfully block file upload requests by annotating @filesecurityannotation on the methods that need to be intercepted.
@FileSecurityAnnotation
@PostMapping("/file")
public String starter(@RequestParam("file") MultipartFile file) {
return "success";
}
file:
#prefix black list
upload-prefix-black-list: ".exe"
#prefix white list
upload-prefix-white-list: ""
#MIME white list
uploadMIMEWhiteList: "image/jpeg"
#MIME black list
uploadMimeBlackList: ""
#validate hash value of file
hashCodeValidate: "MD5"