diff --git a/frappe/hooks.py b/frappe/hooks.py index fdc0afa1ac..c603156b0a 100644 --- a/frappe/hooks.py +++ b/frappe/hooks.py @@ -371,6 +371,7 @@ global_search_doctypes = { override_whitelisted_methods = { # Legacy File APIs + "frappe.utils.file_manager.download_file": "download_file", "frappe.core.doctype.file.file.download_file": "download_file", "frappe.core.doctype.file.file.unzip_file": "frappe.core.api.file.unzip_file", "frappe.core.doctype.file.file.get_attached_images": "frappe.core.api.file.get_attached_images", diff --git a/frappe/utils/file_manager.py b/frappe/utils/file_manager.py index 9aafeb6dfa..ac6a705353 100644 --- a/frappe/utils/file_manager.py +++ b/frappe/utils/file_manager.py @@ -395,27 +395,6 @@ def get_file_name(fname, optional_suffix): return fname -@frappe.whitelist() -def download_file(file_url): - """ - Download file using token and REST API. Valid session or - token is required to download private files. - - Method : GET - Endpoint : frappe.utils.file_manager.download_file - URL Params : file_name = /path/to/file relative to site path - """ - file_doc = frappe.get_doc("File", {"file_url": file_url}) - file_doc.check_permission("read") - path = os.path.join(get_files_path(), os.path.basename(file_url)) - - with open(path, "rb") as fileobj: - filedata = fileobj.read() - frappe.local.response.filename = os.path.basename(file_url) - frappe.local.response.filecontent = filedata - frappe.local.response.type = "download" - - @frappe.whitelist() def add_attachments(doctype, name, attachments): """Add attachments to the given DocType"""