fix: Drop file_manager.download_file (#26575)
Closes https://github.com/frappe/frappe/issues/26424
This commit is contained in:
parent
148b3f771d
commit
a71df1839f
2 changed files with 1 additions and 21 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue