From d3a70b3bee525bf8323876ff8eb3fdc6ec5b3d8e Mon Sep 17 00:00:00 2001 From: rykci Date: Tue, 7 Mar 2023 15:58:14 -0500 Subject: [PATCH] after upload, build the object for UI --- mcs/api/bucket_api.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mcs/api/bucket_api.py b/mcs/api/bucket_api.py index d68d132..a33a8ef 100644 --- a/mcs/api/bucket_api.py +++ b/mcs/api/bucket_api.py @@ -183,10 +183,19 @@ def upload_file(self, bucket_name, object_name, file_path, replace=False): result = self._merge_file(bucket_id, file_hash, file_name, prefix) file_id = result['data']['file_id'] file_info = self._get_file_info(file_id) + self._create_folders(bucket_name, prefix) logging.info("\033[32mFile upload successfully\033[0m") return file_info logging.error("\033[31mFile already exists\033[0m") return None + + def _create_folders(self, bucket_name, path): + bucket_id = self._get_bucket_id(bucket_name) + path, folder_name = object_to_filename(path) + while folder_name: + params = {"file_name": folder_name, "prefix": path, "bucket_uid": bucket_id} + self.api_client._request_with_params(POST, CREATE_FOLDER, self.MCS_API, params, self.token, None) + path, folder_name = object_to_filename(path) def _upload_to_bucket(self, bucket_name, file_path, prefix=''): if os.path.isdir(file_path):