RestTemplate上传文件,不正确的Mime类型?

时间:2012-06-25 15:33:37

标签: spring groovy mime-types apache-tika

我们尝试使用3.0.5.RELEASE中的org.springframework.web.client.RestTemplate作为REST调用的一部分进行文件上传,我们看到一些文件,几乎所有的Open Office和OOXML格式显示为application / octet-stream的服务器端默认值。

我们可以在上传之前使用Tika检测mime类型,但是看不到如何通过RestTemplate将其添加到部分请求中。下面是我们用来执行上传的一些Groovy代码:

MultiValueMap<String, Object> form = new LinkedMultiValueMap<String, Object>()
form.add("title", document.title)
form.add("description", document.description)
form.add("content", new FileSystemResource(file))
return restTemplate.postForObject(getFullURL(REST_API_URI), form, Document.class)

0 个答案:

没有答案
相关问题