fileUpload Documentation
Purpose
The fileUpload logic component is designed to handle file uploads within the Vantage analytics and data platform. Its primary function is to process uploaded files, convert them into a structured format with associated metadata, encode their content in Base64, and if needed, store them in cloud storage services like Google Drive or OneDrive. This allows the platform to capture, manipulate, and store files efficiently for further analysis.
Settings
The fileUpload component has several configuration settings which dictate its behavior and interaction with uploaded files. Below is a detailed breakdown of each setting.
1. uploadedFiles
- Input Type: Array of Objects
- Description: This setting accepts an array where each object represents a file that has been uploaded. Each object should contain properties such as
name,mimeType,size, andbase64(the actual content of the file encoded in Base64). The component processes this array to extract and manage the file data. - Default Value:
[](an empty array)
2. uploadId
- Input Type: String
- Description: This optional string allows the component to identify a specific upload associated with a previous session. It can be used to retrieve file content from Redis if the uploaded files do not already contain the Base64 content.
- Default Value:
''(empty string)
3. saveToDrive
- Input Type: Dropdown (string)
- Options:
"none","googledrive","onedrive" - Description: This setting defines where to save the uploaded files. Selecting
"googledrive"or"onedrive"will enable cloud storage capabilities. Choosing"none"indicates that no files will be stored externally. - Default Value:
"none"
4. driveSubfolder
- Input Type: String
- Description: This optional setting specifies the name of the subfolder under which the uploaded files will be saved in the specified cloud storage. If the subfolder does not exist, it will be created.
- Default Value:
"Uploads"
How It Works
- File Upload Handling: The component starts by checking if any files have been uploaded. If no files are detected, it returns an error message.
- Base64 Content Check: It verifies if the uploaded files contain valid Base64 content. If not, it attempts to retrieve the file content from Redis using the provided
uploadIdor a stableworkflowId. - Row Creation: The component iterates over the
uploadedFiles, capturing their metadata (name, mimeType, size) and computing the Base64 content, along with generating a data URI for image files. - Cloud Storage Integration: Depending on the
saveToDrivesetting, the component establishes a connection with either Google Drive or OneDrive to save the file content in the specified cloud storage service. - Error Handling: Errors during cloud storage interaction are logged, and relevant error messages are associated with the respective files.
- Output Data Structure: The component returns an array of objects containing processed file details and their statuses.
Expected Data
The fileUpload component expects the following data structure in the uploadedFiles setting:
uploadedFiles: [
{
"name": "exampleFile.txt",
"mimeType": "text/plain",
"size": 1234,
"base64": "SGVsbG8gV29ybGQh" // Base64-encoded content
}
]Use Cases & Examples
Use Case 1: Document Management System
A business can utilize the fileUpload component to enable users to upload documents for storage and easy access later. The documents can then be directly uploaded to a designated folder in Google Drive for centralized management.
Use Case 2: Image Gallery Creation
A web application for a photography portfolio can harness this component to allow photographers to upload their images. Each image can be stored alongside its metadata, and additional features such as displaying images on the front-end using data URIs can be easily implemented.
Detailed Example: Enabling Document Upload for Legal Contracts
Consider a legal firm that requires clients to upload contracts digitally for processing and review. The configuration for the fileUpload component could look like this:
{
"uploadedFiles": [
{
"name": "contract_agreement.pdf",
"mimeType": "application/pdf",
"size": 204800,
"base64": "JVBERi0xLjcg....." // Base64-encoded PDF content
}
],
"uploadId": "12345abc",
"saveToDrive": "googledrive",
"driveSubfolder": "Legal Contracts"
}In this example:
- The firm sets
uploadedFileswith the client's contract. - The
uploadIdis used to track the specific upload session. - The firm intends to save the contract to a Google Drive folder named "Legal Contracts" for easy retrieval and compliance purposes.
The configuration enables seamless management of client contracts while utilizing Vantage’s powerful analytics capabilities for processing.