qie.parseMultipartContentFromFile¶
Signature: qie.parseMultipartContentFromFile(inputFile, outputDir*, filenamePrefix*)
Returns: XML Message result - the parsed content as an XML Message
Parse a multipart/related body that was streamed to a file, writing each part to its own file and returning an XML message whose <part> elements carry the on-disk file path.
Note
Unlike qie.parseMultipartContent(...), the part bodies are written to disk rather than base64-encoded into the XML; each <part> carries a <path> element pointing at the extracted part file. The input file is left on disk after parsing - the calling script must clean it up along with each part file. NetFile/CIFS paths are not supported.
Note
See this KB article for a streamed WADO-RS walkthrough.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String or File | inputFile | the streamed multipart response file | |
| String or File | outputDir* | (optional) the directory where the extracted part files are written. When omitted, the parts are written to a sibling subdirectory next to the input file, named after the input file with its last extension stripped (e.g. wado-response-{UUID}.bin → wado-response-{UUID}). | null |
| String | filenamePrefix* | (optional) the filename prefix used for the extracted part files (each part is written as {prefix}-N.{ext}) | part |
Example¶
// Step 1: stream a large multipart/related response body to disk so
// the body never sits in JVM memory.
var responseBodyFile = qie.getStreamPath() + '/wado-response-' + qie.getUUID() + '.bin';
var headers = qie.newParameterMap();
headers.put("http_header_Accept", "multipart/related; type=application/dicom");
qie.callRESTWebService(
"PACS DICOMweb", // connection
qie.getWsEndpointUrl("PACS DICOMweb") + "studies/1.2.3", // url
"GET", // operation
"", // content
null, // contentType
headers, // parameters
60000, // timeout
false, // fullResponse
30000, // connectTimeout
false, // returnBytes
null, // tls
responseBodyFile // streamToFile
);
// Step 2: parse the streamed multipart body into per-part files. The XML
// returned carries the on-disk path to each part.
var partsXml = qie.parseMultipartContentFromFile(
responseBodyFile // inputFile - local path written by streamToFile (left on disk; clean up with qie.deleteFile when done)
); // XML Message: <mtomContent><part>...<path>/.../part-1.dcm</path></part>...</mtomContent>
// Step 3: iterate the parts, copy/process each one, then clean up.
var partCount = partsXml.getCount('/mtomContent/part');
for (var i = 1; i <= partCount; i++) {
var partPath = partsXml.getNode('/mtomContent/part[' + i + ']/path');
// ... process partPath (e.g. C-STORE via DIMSE, copy to share, etc.) ...
qie.deleteFile(partPath); // remove the extracted part once consumed
}
qie.deleteFile(responseBodyFile); // remove the streamed response body file
// Step 4 (optional): control where the part files are written and how they
// are named.
var partsXmlCustom = qie.parseMultipartContentFromFile(
responseBodyFile, // inputFile
"/tmp/wado-extracted", // outputDir - directory to receive the part files
"study-1-instance" // filenamePrefix - files written as study-1-instance-1.dcm, study-1-instance-2.dcm, ...
); // XML Message