Skip to content

Commit 8e7d8d6

Browse files
committed
feat: decode base64 file chunks before uploading
1 parent 6d24d66 commit 8e7d8d6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

apps/application/flow/step_node/tool_lib_node/impl/base_tool_lib_node.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import ast
11+
import base64
1112
import io
1213
import json
1314
import mimetypes
@@ -207,9 +208,13 @@ def execute(self, tool_lib_id, input_field_list, **kwargs) -> NodeResult:
207208
{**all_params, **self.workflow_params.get('data_source'),
208209
'download_item': item},
209210
function_name='download')
210-
file = bytes_to_uploaded_file(ast.literal_eval(result.get('file_bytes')), result.get('name'))
211+
file_bytes = result.get('file_bytes', [])
212+
chunks = []
213+
for chunk in file_bytes:
214+
chunks.append(base64.b64decode(chunk))
215+
file = bytes_to_uploaded_file(b''.join(chunks), result.get('name'))
211216
file_url = self.upload_knowledge_file(file)
212-
download_file_list.append({'file_id': file_url, 'name': result.get('name')})
217+
download_file_list.append({'file_id': file_url.split('/')[-1], 'name': result.get('name')})
213218
result = download_file_list
214219
else:
215220
result = function_executor.exec_code(tool_lib.code, all_params)

0 commit comments

Comments
 (0)