From 4a9af04f94a173d1df9a1ff7f9beb31c48aa4e99 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Wed, 21 Jan 2026 19:10:12 +0530 Subject: [PATCH] fix: update Content-Disposition header for binary as attachment --- frappe/tests/test_api.py | 4 +++- frappe/utils/response.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frappe/tests/test_api.py b/frappe/tests/test_api.py index c1cdb58cde..fe3e551ae0 100644 --- a/frappe/tests/test_api.py +++ b/frappe/tests/test_api.py @@ -483,7 +483,9 @@ class TestAPIResponse(FrappeAPITestCase): self.assertEqual(response.status_code, 200) self.assertEqual(response.headers["content-type"], "application/octet-stream") self.assertGreater(cint(response.headers["content-length"]), 0) - self.assertEqual(response.headers["content-disposition"], f'filename="{encoded_filename}"') + self.assertEqual( + response.headers["content-disposition"], f'attachment; filename="{encoded_filename}"' + ) def test_download_private_file_with_unique_url(self): test_content = frappe.generate_hash() diff --git a/frappe/utils/response.py b/frappe/utils/response.py index 520d2a2837..c0a49f0092 100644 --- a/frappe/utils/response.py +++ b/frappe/utils/response.py @@ -169,7 +169,7 @@ def as_binary(): response.mimetype = "application/octet-stream" filename = frappe.response["filename"] filename = filename.encode("utf-8").decode("unicode-escape", "ignore") - response.headers.add("Content-Disposition", None, filename=filename) + response.headers.add("Content-Disposition", "attachment", filename=filename) response.data = frappe.response["filecontent"] return response