Ticket #15644: django.core.files.base.File.diff

File django.core.files.base.File.diff, 911 bytes (added by nickname123, 14 years ago)

patch

  • django/core/files/base.py

     
    3636        if not hasattr(self, '_size'):
    3737            if hasattr(self.file, 'size'):
    3838                self._size = self.file.size
    39             elif os.path.exists(self.file.name):
     39            elif hasattr(self.file, 'name') and os.path.exists(self.file.name):
    4040                self._size = os.path.getsize(self.file.name)
     41            elif hasattr(self.file, 'tell') and hasattr(self.file, 'seek'):
     42                pos = self.file.tell()
     43                self.file.seek(0,os.SEEK_END)
     44                self._size = self.file.tell()
     45                self.file.seek(pos)
    4146            else:
    4247                raise AttributeError("Unable to determine the file's size.")
    4348        return self._size
Back to Top