I need to validate 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.

For example the following code would fail because the file hasn't been
moved to that destination yet. It's still in memory (or the temporary
directory):

# This is in my Form clean method:
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))

When I look at the "cleaned_data" variable it shows this:
{'xml_file': <InMemoryUploadedFile: texting.nzb (application/octet-
stream)>}

cleaned_data.get('xml_file') only returns "texting.nzb" as a string.

Is there another way to access the the file in memory (or the
temporary directory)?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to