Ticket #8222: 8222.file.storage.rewind.diff

File 8222.file.storage.rewind.diff, 1.1 KB (added by Julien Phalip, 16 years ago)

Patch and regression tests

  • django/django/core/files/storage.py

     
    4343
    4444        self._save(name, content)
    4545
     46        # Rewind file to initial position
     47        content.seek(0)
     48
    4649        # Store filenames with forward slashes, even on Windows
    4750        return force_unicode(name.replace('\\', '/'))
    4851
  • django/tests/regressiontests/file_storage/tests.py

     
    6363
    6464>>> custom_storage.delete(first)
    6565>>> custom_storage.delete(second)
     66
     67# Files should be rewinded to initial position after saving.
     68
     69>>> temp_file = ContentFile('some contents')
     70>>> temp_name = temp_storage.save('temp_file.txt', temp_file)
     71>>> temp_file.read()
     72'some contents'
     73
     74>>> temp_storage.delete(temp_name)
    6675"""
Back to Top