title: spring rest: uploading large files (1GB) via rest controller
body: <p><em>[context: java 8, spring boot 1.5.1]</em></p>
  
  <p>We are creating a RESTful service where we need to be able to upload large files. What I want is an api that would look something like this</p>
  
  <pre><code>@RequestLine("POST /object")
  @Headers("Content-Type: multipart/form-data")
  void create(InputStreamResource resource, ...);
  </code></pre>
  
  <p>I don't want to use a <code>MultipartFile</code> as the entire file would be read, nor an <code>HttpServletRequest</code> as that doesn't seem to belong here but rather begs the need for a <code>HttpMessageConverter</code> of sorts. Having said that, with an <code>HttpServletRequest</code> I could solve the problem as follows</p>
  
  <pre><code>ServletFileUpload upload = new ServletFileUpload();
  FileItemIterator iterator = upload.getItemIterator(request);
  while (iterator.hasNext()) {
    FileItemStream e = iterator.next();
    if (!e.isFormField()) {
      InputStream inputStream = item.openStream();
      //...
    }
  }
  </code></pre>
  
  <p>Ideally I would like an <code>InputStream</code> or something that wraps one, e.g. <code>InputStreamResource</code>(as shown above).</p>
  
  <p>Any suggestions would be appreciated.</p>