Results 1 to 2 of 2

Thread: RestTemplate with Multipart Files.

  1. #1
    Join Date
    Oct 2012
    Posts
    3

    Default RestTemplate with Multipart Files.

    Basically, I need to create a multipart that consists of a 3-Tuple ("srcFile", filename, fileContents). I have tried using a LinkedMultiValueMap<String, LinkedMultiValueMap<String, Object>>, but this results in an HttpConverter missing error.

    In curl this can be done as follows:
    curl -X POST -F "srcFile=@/local/file/test.java;filename=/prepatch/file/test.java"

  2. #2
    Join Date
    Oct 2012
    Posts
    3

    Default

    This blogpost got me on the right track: http://mfjassociates.blogspot.com/

    Instead of representing the multipart files as LinkedMultiValueMap<String, LinkedMultiValueMap<String, Object>>, I needed to represent them as LinkedMultiValueMap<String, HttpEntity<?>> (the type in my case is String, could be FileSystemResource as well). This allowed me to set a HttpHeader for each part, which in turn allowed me to set the filename via the setContentDispositionFormData method. I actually made my parts object LinkedMultiValueMap<String, Object>, which consists of both LinkedMultiValueMap<String, String> and LinkedMultiValueMap<String, HttpEntity<String>>.

Posting Permissions

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