title: Django: Open uploaded file while still in memory; In the Form Clean method?
body: <p>I need to validate the contents of an uploaded XML file in my Form clean method, but I'm unable to open the file for validation. It seams, in the clean method, the file hasn't yet been moved from memory (or the temporary directory) to the destination directory.</p>
  
  <p>For example the following code doesn't work because the file hasn't been moved to that destination yet. It's still in memory (or the temporary directory):</p>
  
  <pre><code>xml_file = cleaned_data.get('xml_file')
  xml_file_absolute = '%(1)s%(2)s' % {'1': settings.MEDIA_ROOT, '2': xml_file}
  xml_size = str(os.path.getsize(xml_file_absolute))
  </code></pre>
  
  <p>When I look at the "cleaned_data" variable it shows this:  </p>
  
  <pre><code>{'xml_file': &lt;InMemoryUploadedFile: texting.nzb (application/octet-stream)&gt;}
  </code></pre>
  
  <p><code>cleaned_data.get('xml_file')</code> only returns "texting.nzb" as a string.</p>
  
  <p>Is there another way to access the the file in memory (or the temporary directory)?</p>
  
  <hr>
  
  <p>Again, this is in my Form's <code>clean</code> method that's tied into the default administration view. I've been told time and time again that all validation should be handled in a Form, not the view. Correct?</p>