Ticket #7812: inmemoryupload_fileseek-r7977.patch

File inmemoryupload_fileseek-r7977.patch, 1.0 KB (added by Ivan Giuliani, 16 years ago)

Fixes .read() behaviour for InMemoryUploadedFile and TemporaryUploadedFile

  • django/core/files/uploadedfile.py

     
    194194        Returns the full path of this file.
    195195        """
    196196        return self._file.name
    197    
     197
    198198    # Most methods on this object get proxied to NamedTemporaryFile.
    199199    # We can't directly subclass because NamedTemporaryFile is actually a
    200200    # factory function
    201     def read(self, *args):          return self._file.read(*args)
     201    def read(self, *args):
     202        self._file.seek(0)
     203        return self._file.read(*args)
     204   
    202205    def seek(self, offset):         return self._file.seek(offset)
    203206    def write(self, s):             return self._file.write(s)
    204207    def close(self):                return self._file.close()
     
    223226        self.seek(0)
    224227
    225228    def read(self, *args, **kwargs):
     229        self.file.seek(0)
    226230        return self.file.read(*args, **kwargs)
    227231
    228232    def chunks(self, chunk_size=None):
Back to Top