Handling Files

How integrators should handle files returned by Keyfax.

How to handle files returned by Keyfax

If users upload files whilst completing a Keyfax script or use a integration such as KeyNect to capture media files during a script Keyfax will return URL’s to these captured files within its results.

This section describes how integrators should handle both Keyfax uploaded files and media files captured via an external integration such as Keyfax KeyNect.

All uploads / files captured during a Keyfax script are returned in a consistent manner. Files will always be added to the Keyfax results within the //Uploads/File element (for XML) or via the Uploads.File array (for JSON).

circle-info

NOTE The Uploads element / property can be found within the <Fault/>, <Enquiry/> or <Call/> element depending on the type of Keyfax script completed. When no files are returned an empty Upload element or Files array is returned.

Keyfax Uploaded Files

During a Keyfax script an "Upload" question type can be presented to the advisor or tenant allowing them to upload one or more files. When files are uploaded during a Keyfax script direct URLs to the uploaded files are returned as part of the Keyfax results. When processing Keyfax results integrators should handle and process the URLs returned by Keyfax.

Handling Keyfax uploaded file URLs would involve the host system programmatically visiting each URL returned by Keyfax and saving the file contents locally within the host systems file system or database.

An example of the XML or JSON returned by Keyfax for Keyfax uploaded files is shown below...

XML

<KeyfaxData>
	<Fault>
		<Uploads>
		    <File><![CDATA[https://keyfax.domain.com/Interview/Main/Uploads/?f=69f4ba78-5895-4111-b479-41e10a2e250f/Wall.png]]></File>
		    <File><![CDATA[https://keyfax.domain.com/Interview/Main/Uploads/?f=24a5ec21-8437-3122-a981-12c22b7d281a/Damp.jpeg]]></File>
		</Uploads>
	</Fault>
</KeyfaxData>

JSON

circle-info

NOTE All URLs returned by Keyfax are wrapped in CDATA to avoid any encoding issues within XML returned by Keyfax. Integrators will need to handle this as part of parsing the Keyfax results.

Example Code

The below code demonstrates how an integrator can sequentially visit each URL returned by Keyfax to download the file locally.

circle-info

IMPORTANT Keyfax uploaded files are permanently deleted 24 hours after the script is completed. For this reason, host systems must visit each returned URL within 24 hours of the completed Keyfax script to download the file locally. After 24 hours the URL will no longer work and will return a 404-status code. The 24-hour clock means file retrieval must happen during result processing and should not be deferred.

KeyNect Captured Files

Similar to files uploaded via Keyfax, files captured through integrations such as Keyfax KeyNect will be returned as URLs within the Keyfax results.

The below examples show the default URLs returned for KeyNect files within the Keyfax results. If you attempt to visit a KeyNect URL you will be prompted to login to your KeyNect account before you can access the file. This is by design but may prevent integrators from automatically downloading and saving the file locally.

XML

JSON

circle-info

NOTE It's important to note that by default with Keyfax KeyNect integrators won't be able to visit the URLs returned by Keyfax directly to automatically download the captured files. Accessing URLs for KeyNect files requires user authentication and so integrators cannot programmatically download these files directly unless specifically enabled by Omfax Systems. If you need to programmatically store media files captured via KeyNect within your own system from Keyfax results please contact Omfax Systems for assistance.

Last updated