I'm trying to upload a file and basically i have a issue with filename encoding, when a send a multipart/form-data with RestTemplate and filename contains character accent like "tésté.pdf", server responds "t?st?.pdf", but when i send with postman/browser it works!
I tried a lot of things, like set MessageConverters with utf-8, convert string to byte and create a new one with utf-8 and set at File, create a new file with name already converted in utf-8 and etc.. I have no more ideas to resolve this problem, i'm using latest version of spring-webmvc, 4.3.2, and still does'nt work.
String url = "https://someurl.com/api";
RestTemplate t = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
File file = new File("/Users/myuser/Desktop/tésté.pdf");
map.add("file", new FileSystemResource(file));
map.add("convert", "false");
map.add("thumb", 0);
String postForObject = t.postForObject(url, new HttpEntity<LinkedMultiValueMap>(map, headers), String.class);