Hi There, So I have a form where users can upload zip and tgz file. In my def clean_file() for class MyForm, I can clean zip files smoothly and now I am trying the same for a tgz file but missing things.
First, fileobj = self.cleaned_data['file'] will return a fileobj, so I tried: tar = tarfile.open(fileobj=fileobj) but then I cannot do anything with 'tar'. I mean, tar.list() returns nothing. Even worse, my fileobj can be any thing, a 'zip' for example, and tarfile.open doesn't seem to check for that as it does if it was a file like 'myfile.tgz' or 'myfile.zip', failing to open for the former. I tried google and also StringIO, but without success. All I want is to check if the supposed tgz file is a valid tgz file as I do for a zip file. Many thanks in avance, Alan -- Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. >>http://www.bio.cam.ac.uk/~awd28<< --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---