From a8293063a5e940104eae698b8ea7a232f7bc1714 Mon Sep 17 00:00:00 2001 From: noirscape Date: Sun, 9 Feb 2025 17:38:40 +0100 Subject: [PATCH 1/4] Read out mimetypes for cached images On Firefox, because there is no mimetype set when serving the file, it is served up as raw HTML, causing cached images to not be served to the client (as the fetch is aborted early). It doesn't appear to be an issue in Google Chrome. This commit fixes #349 . --- maloja/server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/maloja/server.py b/maloja/server.py index c76d9a9..35ae5b3 100644 --- a/maloja/server.py +++ b/maloja/server.py @@ -3,6 +3,7 @@ import os from threading import Thread from importlib import resources import time +from magic import from_file # server stuff @@ -154,7 +155,8 @@ def static_image(pth): @webserver.route("/cacheimages/") def static_proxied_image(uuid): - return static_file(uuid,root=data_dir['cache']('images')) + mimetype = from_file(os.path.join(data_dir['cache']('images'),uuid),True) + return static_file(uuid,root=data_dir['cache']('images'),mimetype=mimetype) @webserver.route("/login") def login(): From a4ec29dd4cef777c8e3983a210ad784a4869afc8 Mon Sep 17 00:00:00 2001 From: noirscape Date: Sun, 9 Feb 2025 17:44:49 +0100 Subject: [PATCH 2/4] Add python-magic to requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index e81dd5d..ffb17a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ lru-dict==1.3.* psutil==5.9.* sqlalchemy==2.0 python-datauri==3.0.* +python-magic==0.4.* requests==2.32.* toml==0.10.* PyYAML==6.0.* From 811bc16a3f7b0168305e42b2aa296dceb15bca26 Mon Sep 17 00:00:00 2001 From: noirscape Date: Sun, 9 Feb 2025 17:46:25 +0100 Subject: [PATCH 3/4] Add libmagic to containerfile --- Containerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Containerfile b/Containerfile index b46c8ae..c6fd44a 100644 --- a/Containerfile +++ b/Containerfile @@ -22,6 +22,7 @@ RUN \ libxslt-dev \ libffi-dev \ libc-dev \ + libmagic \ py3-pip \ linux-headers && \ echo "" && \ From 5926dc33076c10b285f55dca3464aa486ee94bc5 Mon Sep 17 00:00:00 2001 From: noirscape Date: Sun, 9 Feb 2025 17:50:17 +0100 Subject: [PATCH 4/4] its a runtime package --- Containerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Containerfile b/Containerfile index c6fd44a..aaec259 100644 --- a/Containerfile +++ b/Containerfile @@ -22,7 +22,6 @@ RUN \ libxslt-dev \ libffi-dev \ libc-dev \ - libmagic \ py3-pip \ linux-headers && \ echo "" && \ @@ -30,6 +29,7 @@ RUN \ apk add --no-cache \ python3 \ py3-lxml \ + libmagic \ tzdata && \ echo "" && \ echo "**** install pip dependencies ****" && \