How to consume a Multi Part Form with Spring RestTemplate

I want to consume a multi part form body containing both a file and a json component with RestTemplate getForEntity().

Example:

--As2a88kfptKSxKVf56fljTf0XVqkrdEyU Content-Disposition: form-data; name="test.txt" Content-Type: application/octet-stream  test file content --As2a88kfptKSxKVf56fljTf0XVqkrdEyU Content-Disposition: form-data; name="SomeInfo" Content-Type: application/json;charset=UTF-8  {"id":"id1","fileList":["file1","file2"]} --As2a88kfptKSxKVf56fljTf0XVqkrdEyU-- 

I started with:

ResponseEntity<String> response = this.restTemplate.getForEntity(url, String.class); 

Is there a way to extract the two entries without writing a custom parser? The question proofed not very googly.

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.