I believe that as InMemoryUploadedFile is "InMemory", internally uses a 
cStringIO as the "container" for the file. So basically the class it's just 
a wrapper that returns the StringO object, a string representation of the 
file. You should check for the attributes of StringO or maybe use 
SimpleUploadedFile class, maybe that works.

El sábado, 5 de enero de 2013 22:46:02 UTC-3, Braden Walters escribió:
>
> I've had a bit of an issue with InMemoryUploadedFile instances that come 
> in request.FILES to a view. I passed one of them to another constructor to 
> initialise it, and then I tried to access the `encoding` attribute (which 
> appears in the help() for the class). I followed the class hierarchy and 
> found that it leads to FileProxyMixin, where the `encoding` attribute is 
> defined. This is where my mind is blown though:
>
>
>   def __init__(self, f, *args, **kwargs):
>>     print type(f) # => <class 
>> 'django.core.files.uploadedfile.InMemoryUploadedFile'>
>>     print type(f.encoding) # => AttributeError: 'cStringIO.StringO' object 
>> has no attribute 'encoding'
>>
>>
>
> How can it in the first line claim that it is an InMemoryUploadedFile, but 
> in the second line, where I try to access an attribute on it, claim to be a 
> StringO? To test that this issue is not the result of the instance being 
> passed too far into my code (where my code messes something up), I tried 
> the same test in the view directly with the request.FILES['file'] instance, 
> and the same issue occurs. I should be able to continue without this 
> attribute, but now I'm just curious. If anyone knows what's going on, 
> please let me know. Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/MYQvAXCbagIJ.
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