diff --git a/beat/web/common/storage.py b/beat/web/common/storage.py index 8cd096574c01547e6e09b0457da9329a100a7234..0ce2d8c3e411d84d74217062c970dc971661ae7b 100755 --- a/beat/web/common/storage.py +++ b/beat/web/common/storage.py @@ -61,7 +61,7 @@ class OverwriteStorage(FileSystemStorage): # ---------------------------------------------------------- -def get_file_content(instance, attr): +def get_file_content(instance, attr, binary=False): """Reads the contents of a Django-FileField attribute Parameters: @@ -81,8 +81,12 @@ def get_file_content(instance, attr): if f is None: return "" + mode = "rt" + if binary: + mode = "rb" + try: - f.open() + f.open(mode) except Exception: return ""