3

I am wondering why does spring boot convert MultiPartFile file's name special characters into ? (for eg. ééé.pdf gets converted to ???.pdf). Do I need to configure Spring to disabled this behaviour ? I have checked my jvm configuration for file.encoding and it's already set to UTF-8.

I perform the file upload this way :

@PostMapping("/upload")
public void uploadFile(@RequestParam MultipartFile file){
// todo : ...
}
the_tourist
  • 191
  • 2
  • 13
  • 1
    Possible duplicate of [UTF-8 text is garbled when form is posted as multipart/form-data](https://stackoverflow.com/q/546365/5221149) – Andreas Dec 27 '19 at 15:44

1 Answers1

5

You can try this

 String originalFileName = URLDecoder.decode(file.getOriginalFilename(), "UTF-8");

Hope useful for you

A.khalifa
  • 2,366
  • 3
  • 27
  • 40