Skip to main content

Return HTTP Responses as Files: Handling Large Outputs and Binary Content

Learn how to handle large outputs and binary content by converting HTTP responses to files in Torq workflows.

In some cases you may want to receive an HTTP request step's response as a file rather than directly in the workflow context. For example, when the response contains data that exceeds the output size limit, or non-textual binary content such as an image, PDF, or executable file.

This option is available for the Send an HTTP Request step and any step switched to HTTP mode.

You can return the response as a file for the following steps:

  • Send an HTTP Request step

  • Any step that can be switched to HTTP mode

Enable file response

  1. Open Execution Options: In the step's Properties tab, expand the Execution Options section.

  2. Enable file response: Set Return response as file to Yes.

  3. (Optional) Enable shareable link: Set Shareable link to Yes to generate a publicly accessible link. This toggle is only visible when Return response as file is set to Yes.

HTTP request output

When enabled, the step returns a JSON object containing file metadata:

{
"api_object": {
"content_type": "application/json; charset=utf-8",
"filename": "get",
"hashes": {
"md5": "15fff2b2e51d41a12247a0ea1639ee0f",
"sha1": "9f22dac8bd5bb6aecf6c12cb88ee4cee1e18f465",
"sha256": "94feff555d530e167f5cc0715760fce4c39baf258409b781ddd01fa9cf284f1a"
},
"size": 351,
"url": "tqfile://steps/e1d63123-d938-46c3-bd5d-51ef9c26c123"
}
}
  • url: The file URL used to reference the file in subsequent steps. Files are available for 24 hours.

  • hashes: MD5, SHA1, and SHA256 values that can be used to scan online threat databases to verify the file is safe.

  • content_type: Derived from the HTTP response header. The file content type, name, and size (in bytes) can be used as filter criteria in subsequent steps.

Access the file in subsequent steps

To access a private file URL (tqfile://steps/XXXXXXXXX) in a subsequent step, use the file inline function:

{{ file $.send_an_http_request.api_object.url }}

Shareable links (https://link.torq.io/***dEjnLCXnv7) can be accessed directly without the file inline function.

Extract data from the response file

Once you have the file URL, you can pass it to subsequent steps for processing:

  • Extract using regex: Use the Extract all using a regex pattern or Extract all using a regex group step to return every match of a regular expression in the response file.

  • Extract using jq: Use the Run jq Command step to query the response file using jq expressions, for example, to return the [.args] value from the response. This requires prior knowledge of the JSON structure.

Large responses

If the HTTP response exceeds the output size limit, the step will fail or disrupt the workflow run. If your step fails for this reason, or you expect a large response, set Return response as file to Yes to handle the output as a file instead.

Did this answer your question?