Skip to main content
All CollectionsBuild AutomationsSteps
File Usage in Torq Workflows
File Usage in Torq Workflows

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

Updated over a week ago

You can use files in workflows by passing the file links between steps. By default, links to files that are the output of step executions can only be used in Torq steps. This means the file links can't be opened in a browser or shared with external services. There is an option to make the file link shareable.

These are some common ways to use files in workflows:

Important to Know

  • The format for links to files that are outputs of step executions: tqfile://steps/XXXXXXX

  • File links can't be shared externally. They can only be passed in Torq steps using the file inline function.
    Example: {{ file $.send_an_http_request.api_object.url }}

  • Other file links are signed URLs in the format https://link.torq.io/****dEjnLCXnv7. These file links can be shared externally and used in Torq steps without using the file inline function.

Share a File Outside of Torq

These instructions explain how to get a signed URL for a file stored in Torq to share outside Torq. Files will be available for 24 hours and then deleted. To change the expiration period, contact Torq support.

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

  2. Set the Shareable link toggle to Yes.

Example: Return the Response as a File for Use in Subsequent Steps

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

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

  3. Run the step. The file URL appears in the following 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. To extract data from the file, use this expression {{ file $.send_an_http_request.api_object.url }}

Upload a File Using an HTTP Request Step

  1. Add a Send an HTTP request step to the designer.

  2. Set the METHOD to POST.

  3. Add a header to the HEADERS section if you want the file to be interpreted in a specific format (for example, to suit the third-party service requirements).

    1. Key: content-type

    2. Value: file format

  4. Set the body CONTENT_TYPE parameter to raw binary.

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

Use File Content within Workflow Context

Follow these steps to get file content into the workflow context for data manipulation, use with third-party services, share with other users, and more.

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

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

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

  4. The file content will appear as the value of the api_object key in the step output.

Use Files in Inline Scripts

To access the content of a file in an inline script, you first need to apply the Get method to the file URL.

The example below shows a Python inline script, but the same applies to other scripting languages, such as Javascript, Bash, etc.

Use the file inline function for non-shareable file URLs that have the format: tqfile://steps/XXXXXX

Shareable URLs don't require the file inline function: https://link.torq.io/***dEjnLCXncv7

Binary Files

If the tqfile you're trying to retrieve into the workflow execution context is not an ASCII file but a binary file, you'd probably want to consider adding the Base64 response body parameter to the Send an HTTP Requeststep and set it to Yes. With that the content of the binary file will be returned and added to the workflow execution context as a Base64 encoded string.

Did this answer your question?