Skip to main content
The upload_file method uploads a file to Narada cloud, making it available for use as an attachment in subsequent agent requests. This is particularly useful for document analysis, data extraction, and any task where the agent needs to process file content.
Uploaded files are temporarily stored and expire after 24 hours. Files can only be accessed by the user who uploaded them.

Method Signature

async def upload_file(
    self,
    *,
    file: IO,
) -> File

Parameters

file
IO
required
A file object opened in binary read mode. The file can be any format supported by the agent (PDF, images, documents, etc.).
with open("/path/to/document.pdf", "rb") as f:
    file = await window.upload_file(file=f)

Return Value

Returns a File object that can be passed to the agent method’s attachment parameter.

Example

import asyncio
from narada import Agent, Narada

async def main():
    async with Narada() as narada:
        window = await narada.open_and_initialize_browser_window()

        # Upload a file
        with open("/path/to/report.pdf", "rb") as f:
            file = await window.upload_file(file=f)

        # Use the uploaded file in an agent request
        response = await window.agent(
            prompt="Summarize the key points from the attached report",
            agent=Agent.GENERALIST,
            attachment=file
        )

        print(f"Summary: {response.text}")

if __name__ == "__main__":
    asyncio.run(main())
For a complete example showing file attachments with structured data extraction, see the File Attachments example in the agent documentation.