Results 1 to 2 of 2

Thread: RestTemplate Uploading File, incorrect Mime-type?

  1. #1

    Angry RestTemplate Uploading File, incorrect Mime-type?

    Hello,

    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:

    Code:
    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. #2

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •