Skip to main content

File Usage in Torq Workflows

Learn how to incorporate file usage into Torq workflows, optimizing effciency and flexibility in data handling.

Overview

Files are passed between steps in Torq workflows using file links. By default, file links generated by step executions are private and can only be used within Torq steps, they cannot be opened in a browser or shared with external services. You can optionally make a file link shareable for external use.

The file() function is not supported within Operators.

Private and public file links

Private links

Private file links can only be accessed within Torq workflows and cannot be opened in a browser or shared externally. They can only be passed between Torq steps using the file inline function.

  • Usage: {{ file $.send_an_http_request.api_object.url }}

  • Best for: Sensitive or internal files where external access is not required, such as internal processing, enrichment, or automation.

Public (shareable) links

Shareable links allow a file to be opened in a browser or accessed outside of Torq. Files are available for 24 hours before being automatically deleted.

Common use cases

Examples

Share a file outside of Torq

Generate a shareable URL for a file stored in Torq to share or download outside the platform.

  1. Enable Return response as file: In the step's Execution Options section, set the Return response as file toggle to Yes.

  2. Enable Shareable link: Set the Shareable link toggle to Yes. A shareable URL is generated in the format https://link.torq.io/****dEjnLCXnv7, which can be used to download the file or share it externally.

Return the response as a file for use in subsequent steps

Return a step's output as a downloadable file, then pass the file link to later steps for further processing, analysis, or sharing.

  1. Add the step: Add the Send an HTTP request step to the canvas.

  2. Enable Return response as file: Under Execution Options, set the Return response as file toggle to Yes.

  3. Run the step: The file URL appears in the format tqfile://steps/XXXXXX and is available in the step output in the Execution Log. The file URL can only be used in Torq steps.

  4. Extract data from the file: Use the following expression in subsequent steps: {{ file $.send_an_http_request.api_object.url }}

Upload a file using an HTTP request step

Upload a file to an external service using the Send an HTTP Request step.

  1. Add the step: Add a Send an HTTP request step to the Designer.

  2. Set the method: Set METHOD to POST.

  3. (Optional) Add a header: In the HEADERS section, add a header if the file needs to be interpreted in a specific format:

    • Key: content-type

    • Value: File format

  4. Set the content type: Set the CONTENT_TYPE parameter to raw binary.

  5. Set the body: Set BODY to the file URL. For example: {{ file $.prev_step_name.api_object.url }}. Use the file inline function for non-shareable links.

Send a file to Slack from a workflow

Send a file to a Slack channel or user directly from your Torq workflow.

  1. Add the Send Message step: In your workflow, add the Send Message step from the Slack integration.

  2. Specify the recipient: In the RECIPIENT field, enter the Slack channel (#channel-name) or user (@username).

  3. Prepare the file content: If the file content is already available in your workflow context, reference it directly. Otherwise, use a Send an HTTP Request step to pull the file content or URL into the workflow.

  4. Attach the file: In the Send Message step, use the file content or URL in the designated file field.

  5. (Optional) Configure advanced options: Click the cogwheel icon to access additional parameters such as a custom message or metadata.

Ensure the Slack integration is connected and authorized before running the workflow. Configuration may vary depending on file type (text, image, PDF, etc.) and use case.

Use file content within the workflow context

Bring file content into the workflow context for data manipulation, use with third-party services, or sharing with other users.

  1. Add the step: Add a Send an HTTP Request step to your workflow.

  2. Enter the file URL: In the URL parameter, enter the path to the file link.

  3. Apply the inline function: If the link format is tqfile://..., prepend it with the file inline function.

  4. Access the output: The file content appears as the value of the api_object key in the step output.

Use files in inline scripts

To access file content in an inline script, apply the GET method to the file URL. The example below uses Python, but the same approach applies to other scripting languages such as JavaScript and Bash.

import requests
response = requests.get('{{file $.send_an_http_request.api_object.url}}')
print(response.text)

Retrieve binary files

If the tqfile you want to retrieve is a binary file rather than an ASCII file, add the Base64 response body parameter to the Send an HTTP Request step and set it to Yes. The binary file content is returned and added to the workflow execution context as a Base64-encoded string.

Save collected loop results to a file

Store aggregated loop results from a Collect operator into a file for further processing or export.

  1. Add a step after the Collect operator: Once your loop has finished collecting data, insert a step that supports HTTP mode (for example, Send an HTTP Request).

  2. Enable Return response as file: In the step's Properties tab, expand Execution Options and set Return response as file to Yes.

  3. Pass the collected data: Use the output of the Collect operator as the input for this step. The step stores the response as a file and generates a URL in the tqfile://steps/XXXXXXXXX format.

  4. Use the file in later steps: Access the file in subsequent steps using the inline function: {{ file $.step_name.api_object.url }}.

Did this answer your question?