Issues

Issue #96 new

AttributeError: 'S3StorageFile' object has no attribute 'name'

Anonymous created an issue

When reading files, the following error results:

AttributeError: 'S3StorageFile' object has no attribute 'name'

Possible solution: call

{{{

!python

class S3StorageFile(File): def init(self, name, storage, mode): super(S3Storage,self).init(<args>); ? }}}

Comments (6)

  1. Alessandro Pagnin

    I have the same problems with SFTPStorageFile:

    Traceback:

    File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
      111.                         response = callback(request, *callback_args, **callback_kwargs)
    File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py" in wrapper
      307.                 return self.admin_site.admin_view(view)(*args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in _wrapped_view
      93.                     response = view_func(request, *args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
      79.         response = view_func(request, *args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in inner
      197.             return view(request, *args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in _wrapper
      28.             return bound_func(*args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in _wrapped_view
      93.                     response = view_func(request, *args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in bound_func
      24.                 return func(self, *args2, **kwargs2)
    File "/usr/local/lib/python2.6/dist-packages/django/db/transaction.py" in inner
      217.                 res = func(*args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py" in change_view
      982.                 self.save_model(request, new_object, form, change=True)
    File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py" in save_model
      665.         obj.save()
    File "../-------------/------/models.py" in save
      177.         super(Person, self).save(*args, **kwargs)
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py" in save
      460.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py" in save_base
      525.                         values = [(f, None, (raw and getattr(self, f.attname) or f.pre_save(self, False))) for f in non_pks]
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/files.py" in pre_save
      252.         file = super(FileField, self).pre_save(model_instance, add)
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/__init__.py" in pre_save
      257.         return getattr(model_instance, self.attname)
    File "/usr/local/lib/python2.6/dist-packages/django/db/models/fields/files.py" in __get__
      193.             file_copy = self.field.attr_class(instance, self.field, file.name)
    

    Exception Type: AttributeError at /admin/-------/person/395/ Exception Value: 'SFTPStorageFile' object has no attribute 'name'

  2. Anonymous

    Was there ever a resolution to this bug? I am also getting it when trying to open an image from S3.

    image = Image.open(default_storage.open(image_url2))

    Traceback (most recent call last): File "<console>", line 1, in <module> File "/Users/emile/Sites/tindiev2/lib/python2.6/site-packages/PIL/Image.py", line 1952, in open fp = builtin.open(fp, "rb") IOError: [Errno 2] No such file or directory: 'https://s3.amazonaws.com/xxxxxx/product/5.jpg'

    Traceback (most recent call last): File "<console>", line 1, in <module> File "/Users/emile/Sites/tindiev2/lib/python2.6/site-packages/django/core/files/base.py", line 27, in repr return "<%s: %s>" % (self.class.name, self or "None") File "/Users/emile/Sites/tindiev2/lib/python2.6/site-packages/django/core/files/base.py", line 30, in nonzero return bool(self.name) AttributeError: 'S3StorageFile' object has no attribute 'name'

  3. emilepetrone

    To make this easier to read- sorry about that:

    Traceback (most recent call last):

    File "<console>", line 1, in <module>

    File "/Users/emile/Sites/tindiev2/lib/python2.6/site-packages/django/core/files/base.py", line 27, in repr return "<%s: %s>" % (self.class.name, self or "None")

    File "/Users/emile/Sites/tindiev2/lib/python2.6/site-packages/django/core/files/base.py", line 30, in nonzero return bool(self.name)

    AttributeError: 'S3StorageFile' object has no attribute 'name'

  4. Log in to comment