title: How to save Mono<FilePart> to MongoDB?
body: <p>I'm trying to save a form data (including some files) coming from the front-end:</p>
  
  <pre><code>React:
  handleSubmit = (e) =&gt; {
          e.preventDefault();
          e.stopPropagation();
          const { authors, title, genre, description, content, cover} = this.state;
          let formData = new FormData();
          formData.append('authors', authors);
          formData.append('title', title);
          formData.append('genre', genre);
          formData.append('description', description);
          formData.append('content', content, content.name);
          formData.append('cover', cover, cover.name);
          postBook(formData)
              ...
      };
  
  ...
  
  export function postBook(formData) {
      return fetch('/api/books/', {
          method: 'post',
          body: formData
      });
  }
  </code></pre>
  
  <p>On back-end I'm trying to use WebFlux and save data from web form to MongoDB:</p>
  
  <pre><code>@RestController
  @RequestMapping("api/books")
  public class BookController {
     ...
  @PostMapping(value = "/", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
      public Mono&lt;BookDto&gt; addNewBook(
              @RequestPart("authors") Mono&lt;FormFieldPart&gt; aut,
              @RequestPart("title") Mono&lt;FormFieldPart&gt; tle,
              @RequestPart("genre") Mono&lt;FormFieldPart&gt; gnr,
              @RequestPart("description") Mono&lt;FormFieldPart&gt; descr,
              @RequestPart("content") Mono&lt;FilePart&gt; cont,
              @RequestPart("cover") Mono&lt;FilePart&gt; cov) {
          Mono&lt;String&gt; authors = aut.map(FormFieldPart::value);
          Mono&lt;String&gt; title = tle.map(FormFieldPart::value);
          Mono&lt;String&gt; genre = gnr.map(FormFieldPart::value);
          Mono&lt;String&gt; description = descr.map(FormFieldPart::value);
          Flux&lt;DataBuffer&gt; content = cont.flatMapMany(Part::content);
          Flux&lt;DataBuffer&gt; cover = cov.flatMapMany(Part::content);
          return bookService.addNewBook(authors, title, genre, description, content, cover)
                  .map(mapper::mapBookToDto)
                  .switchIfEmpty(Mono.error(new Exception()));
      }
  }
  
  @Service
  public class BookServiceImpl implements BookService {
    private GridFsTemplate fsTemplate;
  
    @Override
      public Mono&lt;Book&gt; addNewBook(Mono&lt;String&gt; authors, 
                                   Mono&lt;String&gt; title, 
                                   Mono&lt;String&gt; genre, 
                                   Mono&lt;String&gt; description, 
                                   Flux&lt;DataBuffer&gt; content, 
                                   Flux&lt;DataBuffer&gt; cover) {
          ???
          return null;
      }
  }
  </code></pre>
  
  <p>The problem is to save file in form of <code>Flux&lt;DataBuffer&gt;</code> to MongoDB. I was trying to use something like this:</p>
  
  <pre><code>content.flatMap(DataBuffer::asInputStream).flatMap(is -&gt; fsTemplate.store(is))
  </code></pre>
  
  <p>But it doesn't seem to work. Is there a way to save <code>Mono&lt;FilePart&gt;</code> to MongoDB as one file? </p>
  
  <p>I would appreciate your help.</p>