Download data
Download file
Section titled “Download file”The read()
method returns a bytes
object.
from agentbox import Sandbox
sandbox = Sandbox(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxxx",
template="wemmodr8mb2uk3kn7exw",
timeout=120
)
# Read file from sandbox (returns bytes)
content = sandbox.files.read('/path/in/sandbox')
# Write file to local filesystem in binary mode
with open('/local/path', 'wb') as file:
file.write(content)
from agentbox import AsyncSandbox
sandbox = await AsyncSandbox.create(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxx",
template="wemmodr8mb2uk3kn7exw",
timeout=120
)
# Read file from sandbox (returns bytes)
content = await sandbox.files.read('/path/in/sandbox')
# Write file to local filesystem in binary mode
with open('/local/path', 'wb') as file:
file.write(content)