title: Spring Boot, upload any amount of files in REST controller
body: <p>I'd like to create an endpoint which accepts any amount od different files from user.</p>
  <p>For example:</p>
  <p><a href="https://i.stack.imgur.com/STpF4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/STpF4.png" alt="enter image description here" /></a></p>
  <p>Then, I'd like to receive it in my controller as a <code>Map&lt;String, FilePart&gt;</code> (or any other structure from which I'll know which file is which):</p>
  <pre><code>{
      &quot;file1&quot;: &quot;cactus-logo.png&quot;,
      &quot;file2&quot;: &quot;logo.png&quot;,
      &quot;file3&quot;: &quot;logo.png&quot; (this one is actually different than file2 but has the same name)
  }
  </code></pre>
  <hr />
  <hr />
  <hr />
  <p>I tried some combinations of <code>@RequestPart</code>...</p>
  <ol>
  <li><p>When I do:</p>
  <pre><code>@RequestPart Map&lt;String, FilePart&gt; files
  </code></pre>
  </li>
  </ol>
  <p>or</p>
  <pre><code>    @RequestPart MultiValueMap&lt;String, FilePart&gt; files
  </code></pre>
  <p>I'm getting:</p>
  <blockquote>
  <p>org.springframework.web.server.ServerWebInputException: 400 BAD_REQUEST &quot;Required request part 'files' is not present&quot;</p>
  </blockquote>
  <ol start="2">
  <li><p>When I do:</p>
  <pre><code>@RequestPart(&quot;files&quot;) List&lt;FilePart&gt; files
  </code></pre>
  </li>
  </ol>
  <p>I need to submit files like that:</p>
  <p><a href="https://i.stack.imgur.com/FEazE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FEazE.png" alt="enter image description here" /></a></p>
  <p>And then I don't have the information which file is which (if they have the same name):</p>
  <p><a href="https://i.stack.imgur.com/F6tXM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F6tXM.png" alt="enter image description here" /></a></p>
  <ol start="3">
  <li><p>Finally, I can do:</p>
  <pre><code>     @RequestPart(&quot;file1&quot;) FilePart file1,
       @RequestPart(&quot;file2&quot;) FilePart file2,
       @RequestPart(&quot;file3&quot;) FilePart file3
  </code></pre>
  </li>
  </ol>
  <p>And then it works as expected, but with that, it's possible to submit always only 3 files. I'd like to submit any number of files.</p>
  <ol start="4">
  <li><p>As suggested in comments:</p>
  <pre><code>     @PutMapping(value = &quot;/{component}&quot;, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
       public void upload(
            @RequestParam Map&lt;String, MultipartFile&gt; files
       ) throws IOException {
  </code></pre>
  </li>
  </ol>
  <p>and the map is always empty:</p>
  <p><a href="https://i.stack.imgur.com/Ma8f0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ma8f0.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/9I2yc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9I2yc.png" alt="enter image description here" /></a></p>