From c443a7eb758f2930183ee9f801a808980bb1f225 Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Mon, 19 Aug 2024 11:18:41 +0530 Subject: [PATCH] fix: add whitelist decorater for file content method --- cloud_storage/cloud_storage/overrides/file.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cloud_storage/cloud_storage/overrides/file.py b/cloud_storage/cloud_storage/overrides/file.py index 9beef09..8ab1a7d 100644 --- a/cloud_storage/cloud_storage/overrides/file.py +++ b/cloud_storage/cloud_storage/overrides/file.py @@ -1,3 +1,6 @@ +# Copyright (c) 2024, AgriTheory and contributors +# For license information, please see license.txt + import json import os import re @@ -168,6 +171,7 @@ def remove_file_association(self, dt: str, dn: str) -> None: association.idx = idx self.save() + @frappe.whitelist() def get_content(self) -> bytes: if self.is_folder: frappe.throw(_("Cannot get file contents of a Folder")) @@ -182,7 +186,6 @@ def get_content(self) -> bytes: if self.file_url: self.validate_file_url() - file_path = quote(self.get_full_path()) if self.file_url.startswith("/api/method/retrieve"): client = get_cloud_storage_client() @@ -191,7 +194,7 @@ def get_content(self) -> bytes: elif self.file_url.startswith("http://") or self.file_url.startswith("https://"): self._content = urlopen(self.file_url).read() else: - # read the file + file_path = quote(self.get_full_path()) with open(file_path, mode="rb") as f: self._content = f.read() try: