From 644ccb29a4d665642bf479584af4e160c9fd9a36 Mon Sep 17 00:00:00 2001 From: Davin Martin Date: Mon, 5 Oct 2026 12:51:19 -0400 Subject: [PATCH 1/3] Add replace=False to upload_local_file_to_custom_folder() --- seatable_api/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seatable_api/main.py b/seatable_api/main.py index e5f4ce0..55323b8 100644 --- a/seatable_api/main.py +++ b/seatable_api/main.py @@ -1255,7 +1255,7 @@ def download_custom_file(self, path, save_path): f.write(response.content) @check_auth - def upload_local_file_to_custom_folder(self, local_path, custom_folder_path = None, name=None, ): + def upload_local_file_to_custom_folder(self, local_path, custom_folder_path = None, name=None, replace=False): if not name: name = local_path.strip('/').split('/')[-1] if not custom_folder_path: @@ -1269,7 +1269,7 @@ def upload_local_file_to_custom_folder(self, local_path, custom_folder_path = No response = requests.post(upload_link, data={ 'parent_dir': parent_path, 'relative_path': relative_path, - 'replace': 0 + 'replace': 1 if replace else 0 }, files={ 'file': (name, open(local_path, 'rb')) }, timeout=self.timeout) From 1feb3aa435d63c6941ca504a06c5aaf8a9ee14fc Mon Sep 17 00:00:00 2001 From: Davin Martin Date: Mon, 5 Oct 2026 12:51:26 -0400 Subject: [PATCH 2/3] Add upload_bytes_file_to_custom_folder() --- seatable_api/main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/seatable_api/main.py b/seatable_api/main.py index 55323b8..18d20d8 100644 --- a/seatable_api/main.py +++ b/seatable_api/main.py @@ -1278,6 +1278,28 @@ def upload_local_file_to_custom_folder(self, local_path, custom_folder_path = No file_name = d.get('name') return self.get_custom_file_info(custom_folder_path, file_name) + @check_auth + def upload_bytes_file_to_custom_folder(self, name, content: bytes, custom_folder_path=None, replace=False): + if not custom_folder_path: + custom_folder_path = '/' + + upload_link_dict = self.get_custom_file_upload_link(parse.unquote(custom_folder_path)) + upload_link = upload_link_dict.get('upload_link') + '?ret-json=1' + parent_path = upload_link_dict.get('parent_path') + relative_path = upload_link_dict.get('relative_path') + + response = post(upload_link, data={ + 'parent_dir': parent_path, + 'relative_path': relative_path, + 'replace': 1 if replace else 0 + }, files={ + 'file': (name, BytesIO(content)) + }, timeout=self.timeout) + d = response.json()[0] + + file_name = d.get('name') + return self.get_custom_file_info(custom_folder_path, file_name) + @check_auth def get_custom_file_info(self, path, name): url = self._app_custom_asset_file_url() From 273e38c5447c1c11ee4b3c57123226dbe87ed609 Mon Sep 17 00:00:00 2001 From: Davin Martin Date: Tue, 6 Oct 2026 09:21:36 -0400 Subject: [PATCH 3/3] Import Fix --- seatable_api/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seatable_api/main.py b/seatable_api/main.py index 18d20d8..c852f0f 100644 --- a/seatable_api/main.py +++ b/seatable_api/main.py @@ -1288,12 +1288,12 @@ def upload_bytes_file_to_custom_folder(self, name, content: bytes, custom_folder parent_path = upload_link_dict.get('parent_path') relative_path = upload_link_dict.get('relative_path') - response = post(upload_link, data={ + response = requests.post(upload_link, data={ 'parent_dir': parent_path, 'relative_path': relative_path, 'replace': 1 if replace else 0 }, files={ - 'file': (name, BytesIO(content)) + 'file': (name, io.BytesIO(content)) }, timeout=self.timeout) d = response.json()[0]