mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Add more allowed file types
This commit is contained in:
parent
9a4ab645dc
commit
c824ae4f6d
@ -31,6 +31,15 @@ class ShibbolethAuthenticator:
|
|||||||
RETRY_DELAY = 1 # seconds
|
RETRY_DELAY = 1 # seconds
|
||||||
CHUNK_SIZE = 1024**2
|
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):
|
def __init__(self, cookie_path=None):
|
||||||
self._cookie_path = cookie_path
|
self._cookie_path = cookie_path
|
||||||
|
|
||||||
@ -185,7 +194,7 @@ class ShibbolethAuthenticator:
|
|||||||
for t in range(self.RETRY_ATTEMPTS):
|
for t in range(self.RETRY_ATTEMPTS):
|
||||||
try:
|
try:
|
||||||
async with self._session.get(url, params=params) as resp:
|
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)
|
# Yay, we got the file (as long as it's a PDF)
|
||||||
await utils.stream_to_path(resp, to_path)
|
await utils.stream_to_path(resp, to_path)
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user