Announcement Announcement Module
No announcement yet.
RestTemplate Uploading File, incorrect Mime-type? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • RestTemplate Uploading File, incorrect Mime-type?


    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:

    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)
    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.

  • #2
    I've switched from SaajSoapMessageFactory to AxiomSoapMessageFactory to handle large WS attachments more efficiently. I am using Spring WS 2.1 and Apache Axiom 1.2.13.