@opendatalabs/vana-react - v0.3.1
    Preparing search index...

    Interface VanaAppUploadWidgetHandle

    Imperative handle exposed via ref for programmatic widget control. Provides methods to interact with the widget after operation completion.

    Use this handle when your operation generates artifacts (files) that you need to download and process in your application. Agent operations like prompt_gemini_agent can produce reports, CSVs, images, or other file outputs that are made available via the artifacts array in the result.

    Complete example using ref to download artifacts:

    import { useRef, useState } from 'react';
    import { VanaAppUploadWidget, VanaAppUploadWidgetHandle, AgentOperationResult } from '@opendatalabs/vana-react';

    function App() {
    const widgetRef = useRef<VanaAppUploadWidgetHandle>(null);
    const [downloadedFiles, setDownloadedFiles] = useState<string[]>([]);

    const handleResult = async (result: AgentOperationResult) => {
    console.log('Operation completed:', result.output);

    // Download artifacts if available
    if (result.artifacts && result.artifacts.length > 0) {
    for (const artifact of result.artifacts) {
    try {
    // Download artifact using the ref handle
    const blob = await widgetRef.current?.downloadArtifact({
    operationId: result.operationId,
    artifactPath: artifact.path
    });

    // Process the downloaded artifact
    if (blob) {
    // Option 1: Trigger browser download
    const url = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = artifact.name;
    a.click();
    URL.revokeObjectURL(url);

    // Option 2: Read content for processing
    const text = await blob.text();
    console.log('Artifact content:', text);

    setDownloadedFiles(prev => [...prev, artifact.name]);
    }
    } catch (error) {
    console.error('Failed to download artifact:', error);
    }
    }
    }
    };

    return (
    <div>
    <VanaAppUploadWidget
    ref={widgetRef}
    appId="my-app-123"
    operation="prompt_gemini_agent"
    operationParams={{ goal: "Generate a comprehensive report" }}
    onResult={handleResult}
    onError={(error) => console.error('Error:', error)}
    onAuth={(wallet) => console.log('Authenticated:', wallet)}
    />
    {downloadedFiles.length > 0 && (
    <div>
    <h3>Downloaded artifacts:</h3>
    <ul>
    {downloadedFiles.map(file => <li key={file}>{file}</li>)}
    </ul>
    </div>
    )}
    </div>
    );
    }
    interface VanaAppUploadWidgetHandle {
        downloadArtifact(
            params: { artifactPath: string; operationId: string },
        ): Promise<Blob>;
    }
    Index

    Methods

    • Downloads artifact content from the personal server.

      Parameters

      • params: { artifactPath: string; operationId: string }

        Parameters specifying which artifact to download

        • artifactPath: string

          The artifact path from the AgentOperationResult

        • operationId: string

          The operation ID that generated the artifact

      Returns Promise<Blob>

      Promise resolving to the artifact content as a Blob

      Error if widget is not ready, download fails, or request times out (30s)