def serve_local_file_unauthed(request: HttpRequest, token: str) -> HttpResponse: path_id = get_local_file_path_id_from_token(token) if path_id is None: return json_error(_("Invalid token")) return serve_local(request, path_id, url_only=False)
def serve_local_file_unauthed(request: HttpRequest, token: str, filename: str) -> HttpResponse: path_id = get_local_file_path_id_from_token(token) if path_id is None: raise JsonableError(_("Invalid token")) if path_id.split("/")[-1] != filename: raise JsonableError(_("Invalid filename")) return serve_local(request, path_id, url_only=False)