Skip to content

Commit

Permalink
fix: Drop file_manager.download_file (#26575)
Browse files Browse the repository at this point in the history
Closes #26424
  • Loading branch information
gavindsouza committed May 27, 2024
1 parent 148b3f7 commit a71df18
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
1 change: 1 addition & 0 deletions frappe/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@

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",
Expand Down
21 changes: 0 additions & 21 deletions frappe/utils/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit a71df18

Please sign in to comment.