How to get files from the server in the public folder?

In erpnext I have an xlsx file in sites/[name]/final_setup/[name].xlsx! Now, from the client script, how can I retrieve this file for further processing?

/frappe-bench/sites/[name]/public$ ls
files  final_setup

Hi,

Please check below function, it will give the pointer how to access file:

def import_doc(path, pre_process=None, sort=False):
	if os.path.isdir(path):
		files = [os.path.join(path, f) for f in os.listdir(path)]
		if sort:
			files.sort()
	else:
		files = [path]

	for f in files:
		if f.endswith(".json"):
			frappe.flags.mute_emails = True
			import_file_by_path(
				f, data_import=True, force=True, pre_process=pre_process, reset_permissions=True
			)
			frappe.flags.mute_emails = False
			frappe.db.commit()
		else:
			raise NotImplementedError("Only .json files can be imported")

You can define the file path like /files/your_file_name.xlsx

Thanks,

Divyesh Mangroliya