Version

    Using Static File as Response

    Using a temporary, static file to create an output content can be useful in a number of cases, for example:

    • when a complicated file is created, which cannot be streamed (e.g. Excel with multiple sheets);

    • when reusing an existing graph which already produces a file;

    • for quick mocking of a service with a sample output in a file - the consumer is able to use the service without implementing the service body.

    In the cases above, the content of the file can then be used as a response body without the need to use a combination of reader and writer components. Using this configuration, the response is not streamed, i.e. reading of the static file and writing its content to the response body doesn’t start until after all components in the data service’s body finish.

    In such a case, set the Format of the Output to file:

    data service output file
    Figure 312. Data Service Output Format Set to File

    Then specify the file you want to stream by setting File URL. CloverDX Designer attempts to automatically select the Content Type based on the file extension. If the type is not recognized, select it manually. Next, choose the Charset of the file. Then, check the Set Content-Disposition as attachment option if you want to label the file as 'available for download'. If the metadata is available for the file and the file is of type CSV select it in Metadata field. It will be used in the result preview.

    A similar function in streaming mode, i.e. continuously writing data into response body without storing the file on disk, can be achieved by setting the File URL attribute of the writer in the data services’s body to response:body. Additionally, if you want to label the file as 'available for download', you must specify the Content-Disposition header in the HTTP response using a CTL2 function addResponseHeader or setResponseHeader.