Announcement Announcement Module
Collapse
No announcement yet.
RestTemplate with Multipart Files. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment

    Working...
    X