title: Multi file upload with metadata with relation to every file in a single http request
body: <p>I'm working on a service (front-end and back-end) that will allow to upload multiple files and metadata to every file, so I will be able to generate a specific path to save the files. (metadata will give me all the information about the path). Also, the request will contain information that needs to be saved to DB (this part is working fine), so its all transactional. So the only thing that I can't figure out is how to send and accept metadata to every file.</p>
  
  <p>Front-end: Angularjs</p>
  
  <p>Back-end: Groovy/Java, Spring 3.0</p>
  
  <pre><code>@RequestMapping(value = "/view/single/multi-file", method = POST, produces = APPLICATION_JSON_VALUE)
  def createNewAdjustment(@RequestParam("files") List&lt;List&lt;MultipartFile&gt;&gt; files,
                          @RequestParam("data") List&lt;DataRequest&gt; data){}
  </code></pre>
  
  <p>So in the code above:</p>
  
  <pre><code>- the list of lists: are the files that needs to be processed and saved.
  - the data: is the list of objects that needs to be processed,saved and interconnect them with files.
  </code></pre>
  
  <p>The request payload looks like this:</p>
  
  <pre><code>------WebKitFormBoundaryPve8x58T1pAIsQOS
  Content-Disposition: form-data; name="data"
  
  {"rollNumber":"1111111111111","compId":213131,"adjId":"260b018c-5921-4c1c-aa99-ba8587ee4777"}
  ------WebKitFormBoundaryPve8x58T1pAIsQOS
  Content-Disposition: form-data; name="files"; filename="some.json.gz"
  Content-Type: application/x-gzip
  
  
  ------WebKitFormBoundaryPve8x58T1pAIsQOS
  Content-Disposition: form-data; name="files"; filename="someother.csv.gz"
  Content-Type: application/x-gzip
  
  
  ------WebKitFormBoundaryPve8x58T1pAIsQOS--
  </code></pre>
  
  <p>You can see <strong>'name: "file"'</strong> repeats 2 times and I'm not sure how to set it manually or/and attach more into to the request. Any ideas ?</p>