Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(agent/workspace): Fix GCS workspace binary file upload

Reinier van der Leer797c5bbc13e8
diff --git a/autogpts/autogpt/autogpt/app/agent_protocol_server.py b/autogpts/autogpt/autogpt/app/agent_protocol_server.py
index 29ab004a26..6abd9c8c3f 100644
--- a/autogpts/autogpt/autogpt/app/agent_protocol_server.py
+++ b/autogpts/autogpt/autogpt/app/agent_protocol_server.py
@@ -339,7 +339,6 @@ class AgentProtocolServer:
"""
Create an artifact for the task.
"""
- data = None
file_name = file.filename or str(uuid4())
data = b""
while contents := file.file.read(1024 * 1024):
diff --git a/autogpts/autogpt/autogpt/file_workspace/gcs.py b/autogpts/autogpt/autogpt/file_workspace/gcs.py
index c6ff3fc972..f1203cd570 100644
--- a/autogpts/autogpt/autogpt/file_workspace/gcs.py
+++ b/autogpts/autogpt/autogpt/file_workspace/gcs.py
@@ -75,10 +75,15 @@ class GCSFileWorkspace(FileWorkspace):
"""Write to a file in the workspace."""
blob = self._get_blob(path)
- if isinstance(content, str):
- blob.upload_from_string(content)
- else:
- blob.upload_from_file(content)
+ blob.upload_from_string(
+ data=content,
+ content_type=(
+ "text/plain"
+ if type(content) is str
+ # TODO: get MIME type from file extension or binary content
+ else "application/octet-stream"
+ ),
+ )
if self.on_write_file:
path = Path(path)