From c824ae4f6db8e1e965b8910732e4f13670db9455 Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 27 Nov 2018 10:27:20 +0000 Subject: [PATCH] Add more allowed file types --- PFERD/ilias_authenticators.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/PFERD/ilias_authenticators.py b/PFERD/ilias_authenticators.py index ad10374..4d51d03 100644 --- a/PFERD/ilias_authenticators.py +++ b/PFERD/ilias_authenticators.py @@ -31,6 +31,15 @@ class ShibbolethAuthenticator: RETRY_DELAY = 1 # seconds CHUNK_SIZE = 1024**2 + ALLOWED_CONTENT_TYPES = [ + "application/pdf", + "application/zip", + "text/xml", + "text/plain", + "image/jpeg", + "image/png", + ] + def __init__(self, cookie_path=None): self._cookie_path = cookie_path @@ -185,7 +194,7 @@ class ShibbolethAuthenticator: for t in range(self.RETRY_ATTEMPTS): try: async with self._session.get(url, params=params) as resp: - if resp.content_type in ["application/pdf", "application/zip", "text/xml"]: + if resp.content_type in self.ALLOWED_CONTENT_TYPES: # Yay, we got the file (as long as it's a PDF) await utils.stream_to_path(resp, to_path) return True