diff --git a/caricari/private.py b/caricari/private.py index e59c8e4..1b6c457 100644 --- a/caricari/private.py +++ b/caricari/private.py @@ -104,14 +104,17 @@ async def upload( detail = "File is already in the archive" raise HTTPException(status_code=400, detail=detail) conn.refresh(orig) - data = {"id": orig.id, "path": orig.filepath, - "url": CONFIG['public']['baseurl'] + "/dl/" + orig.filepath - } + data = { + "id": orig.id, + "path": orig.filepath, + "url": CONFIG["public"]["baseurl"] + "/dl/" + orig.filepath, + } if "application/json" in request.headers.get("accept", ""): return data else: return templates.TemplateResponse( - name="ok.html", request=request, context=data) + name="ok.html", request=request, context=data + ) except Exception as exc: Path(temp.name).unlink() raise diff --git a/caricari/public.py b/caricari/public.py index e851bdf..14956b8 100644 --- a/caricari/public.py +++ b/caricari/public.py @@ -49,8 +49,11 @@ async def get_file(path: str): final_path = Path(CONFIG["general"]["files"]) / original.filepath if final_path.exists(): return FileResponse( - # XXX: avoid it being an attachment - final_path, media_type=original.mime, filename=original.name + # XXX: avoid it being an attachment + final_path, + media_type=original.mime, + filename=original.name, + headers={"X-sha256": original.sha256}, ) else: return 404