1
0
mirror of https://github.com/etesync/server synced 2024-11-25 02:08:16 +00:00
etesync-server/etebase_server/fastapi/sendfile/backends/simple.py
Xiretza 163f7766f1 fix: move etebase_fastapi module from toplevel to under etebase_server
This is in preparation for creating a python package, which should only
occupy the "etebase_server" name in the global module namespace.
2022-05-09 17:41:16 +02:00

13 lines
450 B
Python

from fastapi.responses import FileResponse
def sendfile(filename, mimetype, **kwargs):
"""Use the SENDFILE_ROOT value composed with the path arrived as argument
to build an absolute path with which resolve and return the file contents.
If the path points to a file out of the root directory (should cover both
situations with '..' and symlinks) then a 404 is raised.
"""
return FileResponse(filename, media_type=mimetype)