#7712: UploadedFile doesn't act like a file object
---------------------------------+------------------------------------------
          Reporter:  artagnon    |         Owner:  nobody             
            Status:  reopened    |     Milestone:  1.0 beta           
         Component:  Tools       |       Version:  SVN                
        Resolution:              |      Keywords:  upload uploadedfile
             Stage:  Unreviewed  |     Has_patch:  0                  
        Needs_docs:  0           |   Needs_tests:  0                  
Needs_better_patch:  0           |  
---------------------------------+------------------------------------------
Changes (by jacob_od):

  * status:  closed => reopened
  * resolution:  worksforme =>

Comment:

 More info on this one.  This happens because the PIL image plugin
 ImtImagePlugin.py will use the File method readline, IF the first 100
 bytes contain a newline "\n".  This also will only happen if this
 imageplugin is tried before the correct image is loaded.  In
 Image.py:init() an os.listdir() is called and it loops through all
 imageplugins until it finds the right one.  Since os.listdir() returns the
 directories content in arbitrary order you may or may not see this bug.
 PIL loads the different plugins until it finds the right one so for
 instance it will load BMPPlugin and say no this image is not a BMP, then
 it loads JPG and tries and on and on until it finds the correct image
 type....  so if you happen to be unlucky and the machine loads
 ImtImagePlugin.py before it hits your actual image type AND your image
 contains newlines within the first 100 bytes (I believe the image we have
 that does this is a TIFF created with Microsoft Paint), then it will try
 to execute a readline on the image and you see the error.  I guess the
 solution to this would have to be make the Request.FILES more file like
 and implement all file methods.

 Currently this can be worked around by going like this

      file = StringIO.StringIO(request.FILES['ugpFile'].read())
      image = Image.open(file)


 BTW, I TOTALLY <3 DJANGO U GUYZ R THE BEST AND GIVE ME A BILLION WOODIES A
 DAY! THANKS!!!!

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7712#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to