From cdb50bde6507b5f74e660231e7a85d0f5953daef Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Fri, 20 Feb 2026 14:44:44 +0530 Subject: [PATCH 1/3] fix: use actual file name for private files --- frappe/utils/response.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frappe/utils/response.py b/frappe/utils/response.py index ba4a6f7979..5fdd459c95 100644 --- a/frappe/utils/response.py +++ b/frappe/utils/response.py @@ -295,15 +295,15 @@ def download_private_file(path: str) -> Response: raise Forbidden(_("You don't have permission to access this file")) make_access_log(doctype="File", document=file.name, file_type=os.path.splitext(path)[-1][1:]) - return send_private_file(path.split("/private", 1)[1]) + return send_private_file(path.split("/private", 1)[1], filename=file.file_name) FORCE_DOWNLOAD_EXTENSIONS = (".svg", ".html", ".htm", ".xml") -def send_private_file(path: str) -> Response: +def send_private_file(path: str, filename: str | None = None) -> Response: path = os.path.join(frappe.local.conf.get("private_path", "private"), path.strip("/")) - filename = os.path.basename(path) + filename = filename or os.path.basename(path) extension = os.path.splitext(path)[1] as_attachment = extension.lower() in FORCE_DOWNLOAD_EXTENSIONS @@ -329,7 +329,7 @@ def send_private_file(path: str) -> Response: environ=frappe.local.request.environ, conditional=True, as_attachment=as_attachment, - download_name=filename if as_attachment else None, + download_name=filename, ) return response From 57578c8b9e688cd40feaa2408ee1434b251a3718 Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Fri, 20 Feb 2026 16:08:46 +0530 Subject: [PATCH 2/3] fix: add id to download button --- frappe/core/doctype/file/file.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/core/doctype/file/file.js b/frappe/core/doctype/file/file.js index c8122ee0af..3c78f31e93 100644 --- a/frappe/core/doctype/file/file.js +++ b/frappe/core/doctype/file/file.js @@ -90,7 +90,7 @@ frappe.ui.form.on("File", { }, download: function (frm) { - let file_url = frm.doc.file_url; + let file_url = frm.doc.file_url + "?fid=" + frm.doc.name; if (frm.doc.file_name) { file_url = file_url.replace(/#/g, "%23"); } From bcade7a5472f9fd3a816edf045cbd0835539d7c0 Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Fri, 20 Feb 2026 16:21:27 +0530 Subject: [PATCH 3/3] fix: add fid in view file too --- frappe/core/doctype/file/file.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frappe/core/doctype/file/file.js b/frappe/core/doctype/file/file.js index 3c78f31e93..f3f1380855 100644 --- a/frappe/core/doctype/file/file.js +++ b/frappe/core/doctype/file/file.js @@ -3,7 +3,9 @@ frappe.ui.form.on("File", { if (frm.doc.file_url) { frm.add_custom_button(__("View File"), () => { if (!frappe.utils.is_url(frm.doc.file_url)) { - window.open(window.location.origin + frm.doc.file_url); + window.open( + window.location.origin + frm.doc.file_url + "?fid=" + frm.doc.name + ); } else { window.open(frm.doc.file_url); }