We're trying to do a file upload as part of a REST call using org.springframework.web.client.RestTemplate from the 3.0.5.RELEASE and we're seeing some files, almost all of the Open Office and OOXML formats, show up as the default of application/octet-stream
We can detect the mime-type using Tika, but don't see how to add that to part of the request through RestTemplate. Below is some Groovy code that we're using to perform the upload:
Any advice on how to accomplish this? We'd like to just be able to put the mime type as part of the request in case we have extra edge cases where the default functionality doesn't work.
MultiValueMap<String, Object> form = new LinkedMultiValueMap<String, Object>()
form.add("content", new FileSystemResource(file))
return restTemplate.postForObject(getFullURL(REST_API_URI), form, Document.class)