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).

  • 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 (BETA Restricted): if the option is activated, the API is published in a gateway dedicated to APIs with mTLS active by standard. In this case, the access host will be different from the others. The pipeline can have either the External API and the Internal API options simultaneously enabled, but we recommend for both to remain inactive. This parameter doesn’t support API Key and JWT and is under Beta Restricted phase. To use it in your realm, it’s necessary to make a request via chat and Digibee will evaluate your inclusion in the Beta Restricted program.

  • 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 a consumer 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 consumer

  • 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?