title: How to check if MTOM attachment is empty
body: <p>I am developing webservice based on CXF. One of the requests is that client should be able to upload the optional PDF file as a part of message. This was pretty trivial:</p>
  
  <p>I have added this with getter and setter to my transfer object:</p>
  
  <pre><code>@XmlMimeType("application/octet-stream")
  @XmlElement(name = "InvoicePdf", required = false)
  private DataHandler invoicePdf = null;
  </code></pre>
  
  <p>I have also enabled support for MTOM:</p>
  
  <pre><code>Endpoint endpoint = Endpoint.publish("/myWs", new WsImpl(getServletContext()));
  SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
  binding.setMTOMEnabled(true);
  </code></pre>
  
  <p>And the usage:</p>
  
  <pre><code>DataHandler pdf2 = p_invoice.getInvoicePdf();
  //pdf2.getInputStream();
  //pdf2.writeTo(outputstream);
  </code></pre>
  
  <p>Everything works great. I am able to receive and process the file. However there might be the case when client do not upload the file since it is optional. The problem is that even though the client do not sent the file I am not able to notice it.</p>
  
  <ul>
  <li>pdf2 is not null</li>
  <li>pdf2.getInputStream() is not null</li>
  <li>pdf2.getInputStream() contains some data. I would like to skip parsing the input stream and looking for PDF signature. Since it is a lot easier to forward the inputstrem to desired outpustream (write to file)</li>
  <li>I have not found in DataHandler or DataSource (pdf2.getDataSource() ) API any appropriate method or field for determining file existance. I see in debug that the empty DataHandler contains DataSource which length is 9, which is a lot less then correct PDF file. Unfortunately the length property is not accessible at all.</li>
  </ul>
  
  <p>Any idea how to determine if the file was sent or not?</p>