From fb783dda083662305ff075b92e6824189fe387b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ei=C3=9Fler?= <77415730+PatrickDEissler@users.noreply.github.com> Date: Wed, 6 Aug 2025 18:41:59 +0200 Subject: [PATCH] fix: allow download via API, if at least one file copy is downloadable (#33560) --- frappe/handler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frappe/handler.py b/frappe/handler.py index 4b35660e37..3892aedaa2 100644 --- a/frappe/handler.py +++ b/frappe/handler.py @@ -11,6 +11,7 @@ import frappe import frappe.sessions import frappe.utils from frappe import _, is_whitelisted, ping +from frappe.core.doctype.file.utils import find_file_by_url from frappe.core.doctype.server_script.server_script_utils import get_server_script_map from frappe.monitor import add_data_to_monitor from frappe.permissions import check_doctype_permission @@ -230,8 +231,8 @@ def download_file(file_url: str): Endpoints : download_file, frappe.core.doctype.file.file.download_file URL Params : file_name = /path/to/file relative to site path """ - file: File = frappe.get_doc("File", {"file_url": file_url}) - if not file.is_downloadable(): + file = find_file_by_url(file_url) + if not file: raise frappe.PermissionError frappe.local.response.filename = os.path.basename(file_url)