Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Special chars in for MultipartFile file name converted into ? in spring boot

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 : ...
}
like image 849
the_tourist Avatar asked Dec 09 '25 01:12

the_tourist


1 Answers

You can try this

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

Hope useful for you

like image 104
A.khalifa Avatar answered Dec 10 '25 15:12

A.khalifa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!