# Upload Document

The **Upload Document Node** in UPTIQ Workbench provides a seamless way to **ingest documents into a workflow**, enabling users to extract information, process files, and interact with document content dynamically.

This node **supports multiple upload methods**, allowing developers to:\
✅ Accept file uploads **directly from users**.\
✅ Retrieve documents **via signed URLs from external systems**.\
✅ Process **base64-encoded documents** for advanced automation.

Once a document is uploaded, the **node returns a `documentId`**, which serves as a reference for **further processing**—such as:\
🔹 **Extracting text and data from documents**.\
🔹 **Converting documents into images or zipped archives**.\
🔹 **Passing the document to the Prompt Node for AI-driven queries**.\
🔹 **Uploading the file to an external storage system** via pre-signed URLs.

The **Upload Document Node** is a core component in **document-driven workflows**, making it easy to process files dynamically and integrate them with **AI-powered document intelligence**.

### **Configurations**

| Field                                     | Description                                                                               |
| ----------------------------------------- | ----------------------------------------------------------------------------------------- |
| **Upload Method**                         | Defines how the document will be uploaded. Options: `User Input`, `Content`, `SignedURL`. |
| **Supported File Types** (For User Input) | Specifies allowed file types (e.g., `[PDF, DOCX, JPG]`).                                  |
| **Content** (For Content Upload)          | Accepts a **base64-encoded string** representing the document.                            |
| **Signed URL** (For SignedURL Upload)     | A **temporary URL** that enables document upload from an external system.                 |
| **Upload to External System (Optional)**  | Allows uploading the document to a pre-configured **external storage system**.            |

#### **Upload Methods Explained**

1️⃣ **User Input** → Users upload a file directly.

* Example: **A user submits a loan application PDF for processing.**
* Requires specifying **Supported File Types** (e.g., `[PDF, DOCX]`).

2️⃣ **Content** → Uploads a document using a **base64-encoded string**.

* Example: **An automated workflow sends document content for AI processing.**
* Requires providing the **base64 document string** in the Content field.

3️⃣ **SignedURL** → Retrieves documents from an **external storage system** using a **pre-signed URL**.

* Example: **A workflow pulls an invoice from a cloud-based document storage system.**
* Requires specifying a **Signed URL** that grants temporary access for secure file transfer.

#### **Output Format**

After successful execution, the node returns:

```json
{
  "documentId": "a0abf1d4-a4ca-459e-aada-b10947481b9c",
  "key": "/executions/192012/example"
}
```

* **documentId** → Unique identifier for the uploaded document.
* **key** → A reference path that can be used for further processing.

### **Example Use-Cases**

#### **1. Loan Application Processing**

A **loan processing workflow** requires users to **upload financial documents** for verification.

* **Configuration:**
  * **Upload Method:** `User Input`
  * **Supported File Types:** `[PDF, DOCX]`
* **Outcome:**
  * The user uploads their **loan application document**.
  * The **documentId** is returned for further processing (e.g., OCR extraction, AI-based validation).

***

#### **2. AI-Powered Document Summarization**

A workflow needs to extract and summarize the **content of a legal contract** using AI.

* **Configuration:**
  * **Upload Method:** `Content`
  * **Content:** Base64-encoded document string
* **Outcome:**
  * The document is **uploaded without manual user input**.
  * The **documentId** is passed to the **Prompt Node**, where an AI model generates a **contract summary**.

***

#### **3. Retrieving Invoices from Cloud Storage**

A finance workflow needs to **fetch invoices stored in an external system** and process them.

* **Configuration:**
  * **Upload Method:** `SignedURL`
  * **Signed URL:** `"https://cloudstorage.com/get-invoice?token=abc123"`
* **Outcome:**
  * The invoice is **retrieved via the signed URL**, enabling **automated processing** without manual uploads.

### **Key Takeaways for Developers**

✅ **Flexible Upload Options** – Supports **direct user uploads, base64 content processing, and external storage retrieval**.

✅ **Seamless AI Integration** – Uploaded documents can be **passed to AI models for text extraction, summarization, and querying or for any other use in the workflows.**

✅ **Optimized for Document Processing** – Returns a **documentId**, which can be **used in subsequent workflow steps** for conversion, compression, or data extraction. Nodes that can accept this documentId can directly fetch the document content without developers having to send complete document.

✅ **Secure & Scalable** – Supports **pre-signed URLs for secure external storage access**, enabling workflows to fetch documents without exposing sensitive credentials.

By leveraging the **Upload Document Node**, developers can **streamline document-driven automation** and **enhance AI workflows** by **integrating real-time document ingestion into business processes**. 🚀
