X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5913c54d19b8f6775633176032161d49f9b2f1aa..39a72bbc1bbd88a9ca247e8d0bba7002a77eec04:/src/dvcs/storage.py diff --git a/src/dvcs/storage.py b/src/dvcs/storage.py index 6bb5b595..76051aba 100755 --- a/src/dvcs/storage.py +++ b/src/dvcs/storage.py @@ -1,9 +1,15 @@ +# This file is part of FNP-Redakcja, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# from zlib import compress, decompress from django.core.files.base import ContentFile, File from django.core.files.storage import FileSystemStorage +from django.utils.deconstruct import deconstructible +from django.utils.encoding import force_bytes +@deconstructible class GzipFileSystemStorage(FileSystemStorage): def _open(self, name, mode='rb'): """TODO: This is good for reading; what about writing?""" @@ -13,6 +19,7 @@ class GzipFileSystemStorage(FileSystemStorage): return ContentFile(decompress(text)) def _save(self, name, content): - content = ContentFile(compress(content.read())) + data = force_bytes(content.read()) + content = ContentFile(compress(data)) return super(GzipFileSystemStorage, self)._save(name, content)