Scenario: Ingesting Batch Data from Object Storage
Download sequential CSV objects from OCI Object Storage, transform each batch record in Node-RED, and ingest it into OCI IoT.
Use this scenario to replay offline or historical readings so that digital twin history remains complete. The flow is Inject -> Prepare Filename -> Object Storage Download -> Increment Index -> CSV -> Function -> MQTT-OUT.
This scenario uses Object Storage because each CSV file is a discrete object that the flow downloads and processes on demand. If a flow instead needs shared files available through a mounted filesystem path, use File Storage. See Choosing File Storage or Object Storage.
Complete the common scenario setup before starting.
Tasks
Prerequisites
Create an Object Storage bucket for the batch CSV objects. Record the Object Storage namespace and bucket name. Create the Flow Runtime dynamic group, and ensure that the Resource Principal configuration used by the Object Storage node has the Object Storage read policy required to download objects from the bucket.
The Flow Runtime must be able to reach Object Storage and the OCI IoT device host.
Step 1: Creating the Flow Runtime
Step 2: Uploading the Batch CSV Object
Step 3: Configuring the Node-RED Flow
- Open the Flow Runtime editor.
- In the Node-RED editor, open the main menu and select Import.
- Paste the exported flows document or select its file, and then select Import.
- Review the imported nodes and connections, and then select Deploy.
Use the
oci iot flow-runtime update-flowscommand to replace the complete flows document.oci iot flow-runtime update-flows \ --iot-flow-runtime-id <flow-runtime-ocid> \ --flows-document file://<path-to-flows-json>Note
The command replaces the complete flows document. Retrieve and save the current document first if you need a backup.For more information, see Updating Flows for an IoT Flow Runtime.
Run the UpdateIotFlowRuntimeFlows operation to replace the complete flows document.
PUT /20250531/iotFlowRuntimes/{iotFlowRuntimeId}/flows <complete-Node-RED-flows-document>Pass the exported complete Node-RED flows document as the request body. The synchronous operation returns the flows document and doesn't create a work request.
Step 4: Deploying and Running the Flow
- Select Deploy.
- Upload CSV objects to the configured bucket using sequential names such as
iot-data-1.csv,iot-data-2.csv, andiot-data-3.csv. - Trigger the Inject node or wait for its configured interval. Confirm that the Object Storage node downloads the next object.
- Confirm that the counter increments only after an object is downloaded. It must not advance when the next object isn't available.
Step 5: Validating the Batch Data Ingestion
- Confirm that the Object Storage node downloaded the expected CSV object and the CSV node emitted one message for each row.
- Confirm that the gateway row produced topic
dataand the HVAC rows producedhvacs/fr-guide-hvac-01andhvacs/fr-guide-hvac-02. - Use common Console validation to confirm raw or ingested data, snapshot values, and normalized or historical values for all three digital twin instances.
Troubleshooting
- Confirm the Object Storage namespace, bucket name, sequential object name, and Resource Principal configuration.
- Confirm that the Object Storage node returns the downloaded object as a Buffer and that the index-increment Function converts it to UTF-8 text.
- Confirm that
iot-data-<counter>.csvexists before the next poll. The counter advances only after a successful download. - Confirm that the CSV delimiter and first-row column names match the sample.
- Confirm that each row includes a supported
deviceType, a matching external key, and a numeric source timestamp. - Confirm the MQTT device-host connection, gateway credentials, adapter mappings, and target digital twin lifecycle states.
For more information, see Troubleshooting IoT Flow Runtimes.
FAQs
- Why do the CSV object names use a counter?
- The flow processes a predictable sequence such as
iot-data-1.csvandiot-data-2.csv. The counter advances only after a successful download so objects are processed in order. - Why does the Object Storage node use a Resource Principal?
- The Flow Runtime can access the approved bucket without storing user credentials in the flow. Its dynamic group and policy must grant the required read access.
- What happens when the next sequential object doesn't exist?
- The download fails and the counter remains unchanged. Upload the expected object or correct the namespace, bucket, prefix, and counter before triggering the flow again.
- Why is the downloaded Buffer converted to text?
- The CSV node expects text input. The Function node converts the Object Storage response from a Buffer to UTF-8 text before CSV parsing.