Stream to File¶
The Stream: field is available on Web Service mapping functions that use a REST-capable connection type: DICOMweb, Open AI API, REST (Content Encoded), REST (URL Encoded), and Google Cloud Healthcare API. When a value is entered, the response body from the qie.callRESTWebService call is streamed directly to that file path instead of being buffered in JVM memory. Leave the field blank to use the default in-memory behavior.
Path and node-tag templating¶
The path may contain QIE node-tag templates (for example {s:MSH-10} or {UUID}). QIE resolves these at runtime using qie.evaluateTemplate before opening the file. Static paths work equally well.
Parent directory must already exist¶
The streamed write uses Files.newOutputStream, which does not create directories. The parent directory must exist at runtime or the call fails. Ensure it exists in one of two ways:
- Provision the directory on the server ahead of time (recommended for a fixed location).
- Create it from an upstream mapping function by writing into it with
qie.writeFile. The trailingtrueargument creates any missing parent directories:
There is no standalone folder-create API.
Delete the file when done¶
The file is not deleted by QIE after the response body has been written. Use qie.deleteFile in a downstream mapping function or script once you have finished reading and processing the streamed content:
Include a per-message identifier to avoid collisions¶
Multiple processor threads may handle different messages concurrently. If all threads write to the same fixed path, they overwrite each other's data. Include a per-message identifier in the path to give each message its own file:
// Using the HL7 message control ID
var path = qie.evaluateTemplate("/tmp/qie-stream/{s:MSH-10}.bin");
// Or a generated UUID when the message has no natural unique field
var path = "/tmp/qie-stream/" + qie.getUUID() + ".bin";
Keep patient identifiers out of the path¶
The resolved file path may appear in log entries and in the error queue when a channel fails. Avoid embedding patient identifiers (MRN, name, date of birth, etc.) directly in the path. Use an opaque identifier such as qie.getUUID() or a non-PHI message control ID.
Error handling and disk usage¶
If an error occurs during a streaming call, the partially-written file is left on disk. Do not treat the absence of a file as proof that the call succeeded. Inspect the channel's error queue and logs. On high-volume channels that cycle frequently, monitor disk usage in the target directory and ensure your downstream cleanup (qie.deleteFile) runs reliably to prevent accumulation of orphaned files.