reformat
This commit is contained in:
parent
6a3638438a
commit
607213f1c4
2 changed files with 12 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue