All Collections
Triggers
HTTP File Trigger - Downloads
HTTP File Trigger - Downloads

Know the trigger and how to use it.

Rodrigo Lara avatar
Written by Rodrigo Lara
Updated over a week ago

HTTP File Trigger downloads large files in a robust and efficient way, calling the GET method.

Take a look at the configuration parameters of the trigger:

  • Methods: defines the methods accepted by the pipeline (GET, PUT, POST, PATCH and DELETE).

  • Response Headers: headers to be returned by the endpoint when processing in the pipeline is complete. This parameter cannot be left empty and accepts Double Braces. Special characters should not be used in keys, due to possible failures in proxies and gateways.

  • Add Cross-Origin Resource Sharing (CORS) - CORS Headers: add the CORS headers to be returned by the endpoint when processing in the pipeline is complete. Cross-Origin Resource Sharing (CORS) is a mechanism that lets you tell the browser which origins are allowed to make requests. This parameter defines CORS specifically for the pipeline and its constraints. To configure globally rather than individually on each pipeline, see the CORS Global article.


    Important: We use a comma to enter multiple values in a header, but we don't add a space before or after the comma. Special characters should not be used in keys, due to possible failures in proxies and gateways.


  • Form Data Uploads: enables/disables the receipt of the form data upload (multipart form data).

  • Body Uploads: enables/disables the receipt of bodies upload.

  • Body Upload Content Types: define the content types allowed by the pipeline for the bodies upload.

  • Response Content Types: defines the response content types allowed by the pipeline - when configuring this response, you determine the response format.

  • Maximum Timeout: defines the maximum time of expiration (standard = 60000).

  • Maximum Request Size: defines the maximum size of the file in the upload request (in MB) (maximum = 100 MB).

  • External API: if activated, the option publishes the API in an external gateway.

  • Internal API: if activated, the option publishes the API in an internal gateway.

  • mTLS enabled API: if the option is enabled, the API is published to a gateway dedicated to APIs with mTLS enabled by default. In this case, the access host will be different from the others. The pipeline can have both the External API and Internal API options enabled at the same time, but it is recommended to leave them inactive. This parameter does not support API Key and JWT. To use it in your realm, it is necessary to make a request via chat and we will send you the necessary information to install this service.

  • API Key: if activated, the option will request the key for the API consumption.

  • Token JWT: if activated, the option will request the token for the API consumption.

  • Additional API Routes: if activated, the option allows you to add new routes.

  • API Routes: custom routes.

  • Security (Legacy): if activated, the option determines the need to use a JWT token to access the exposed API.

  • Allow Redelivery Of Messages: if activated, the option allows messages to be redelivered in case of Pipeline Engine failure.

HTTP File Trigger in Action

Scenario: GET with any content type

Let's say you have a file with more than 5MB. You can call a pipeline endpoint configured with HTTP Trigger via GET with any content type for the request to be received and treated. The file is returned according to the output content type and its "as-is" content.

For that to happen, all you have to do is follow these steps:

  1. Create a pipeline and configure its trigger as HTTP-File, including the GET method and the accepted Response Content Types.

  2. Insert a File Connector in the pipeline to search the file to be enabled. You can, for example, configure WGet to obtain a file of a URL sent to the endpoint during a call.

  3. Insert JSON Generator Connector as the last step of your pipeline so that a JSON is generated in the following format:

{
"file": "file-download.pdf",
"Content-Type": "application/pdf"
}


IMPORTANT: this step is fundamental for HTTP File Trigger to understand that the file works.


4. Deploy the pipeline.

5. Create an API Key and configure it so that it has access to the pipeline.

6. Call the pipeline through this curl:

curl https://godigibee.io/pipeline/realm_name/v1/pipeline_name -v -H 'Content-Type: application/pdf' -H 'apikey: generated_token' -H 'urlDownload: http://url/path'

  • realm_name: refers to the Realm where the pipeline is located

  • generated_token: refers to the API Key generated by the recently created API Key

  • urlDownload: parameter sent for WGet Connector to solve the value of the URL field. The attribute isn't mandatory, but allows a more flexible approach through Double Braces. It works perfectly if you define the "path" directly in WGet Connector.

HTTP File Trigger Response

It's simple to define the pipeline response format. Add a Transformer to the end of the pipeline and define the response:

{
"file": "file-download.pdf",
"code": 200,
"Content-Type": "application/pdf"
}


IMPORTANT: Content-Type must be one of the values defined in Response Content Types.


HTTP File Trigger responds to bodies that aren't files in the same way HTTP Trigger does. It allows the pipeline to respond with the file or with any other according to the invocation context. For HTTP File Trigger to respond with any body, the last step of the pipeline must have this structure:

{
"body": "information that will be written in the endpoint output",
"Content-Type": "body content type",
"code": <a HTTP return code>
}


IMPORTANT: Content-Type must be one of the values defined in Response Content Types.




Did this answer your question?