title: spring webflux FilePart how to validate mime type?
body: <p>Given the controller mapping below, I wonder how to validate that the provided file is an image with maximum file size.</p>
  <pre><code>@PostMapping(&quot;/users/avatar&quot;)
  suspend fun uploadAvatar(@RequestPart(&quot;file&quot;) filePartMono: Mono&lt;FilePart&gt;) {
    filePartMono.map{ part -&gt; part.content().map{ it.asInputStream().readAllBytes() }
      .map { it /* ??? */ }
    }
    // ...
  }
  </code></pre>
  <p>On the non-reactive stack I did it like this:</p>
  <pre><code>uploadAvatar(@RequestParam(&quot;file&quot;) MultipartFile file) {
      String contentType = file.getContentType().toLowerCase();
      List&lt;String&gt; valid = Arrays.asList(&quot;image/jpg&quot;, &quot;image/jpeg&quot;, &quot;image/png&quot;);
      if (file.isEmpty() || !valid.contains(contentType)) {
          throw new UploadException(&quot;Invalid image format or empty file&quot;, HttpStatus.UNPROCESSABLE_ENTITY);
      }
      if (file.getSize() &gt; IMAGE_MAX_FILE_SIZE) {
          throw new UploadException(&quot;Image too big (max &quot; + (IMAGE_MAX_FILE_SIZE / 1000) + &quot; kB )&quot;, HttpStatus.UNPROCESSABLE_ENTITY);
      }
      try {
          // try to read file as image to ensure it is an image
          ImageIO.read(file.getInputStream());
      } catch (IOException e) {
          throw new UploadException(&quot;Invalid image&quot;, HttpStatus.UNPROCESSABLE_ENTITY);
      }
  
      try {
          byte[] bytes = file.getBytes();
          userService.storeAvatar(bytes);
      } catch (IOException e) {
          throw new UploadException(&quot;Could not store image&quot;, HttpStatus.INTERNAL_SERVER_ERROR);
      }
  }
  </code></pre>
  <p>but FilePart does not provide the same API (e.g. contentType).</p>
  <p>How can I obtain contentType and file size from the <code>FilePart</code>?</p>