Ticket #8204: 8204.storage_save.diff

File 8204.storage_save.diff, 918 bytes (added by Julien Phalip, 16 years ago)

Adding a fall back option for other kinds of file contents

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

     
    153153            # This file has a file path that we can move.
    154154            file_move_safe(content.temporary_file_path(), full_path)
    155155            content.close()
    156         else:
     156        elif hasattr(content, 'chunks'):
    157157            # This is a normal uploadedfile that we can stream.
    158158            fp = open(full_path, 'wb')
    159159            locks.lock(fp, locks.LOCK_EX)
     
    161161                fp.write(chunk)
    162162            locks.unlock(fp)
    163163            fp.close()
     164        else:
     165            # Fallback for other types of content (e.g. PIL Image)
     166            content.save(full_path)
    164167
    165168    def delete(self, name):
    166169        name = self.path(name)
Back to Top