HTTP File Trigger - Downloads

Discover more about the HTTP File Trigger and how to use it on the Digibee Integration Platform.

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

Parameters

Take a look at the configuration options for the component. Parameters supported by Double Braces expressions are marked with (DB).

There is a global configuration parameter that obliges all the pipelines to be published with at least the API Key or Basic Auth options enabled.

Parameters additional information

Add Cross-Origin Resource Sharing (CORS) - CORS Headers

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.

Remove Digibee Prefix from Route

As previously explained, this option is recommended for removing the default Digibee route prefix from the pipeline route.

Let’s say you’ve created a pipeline and set the trigger as follows:

With the configurations applied and the pipeline deployed, you will get a new URL:

https://test.godigibee.io/products

When removing the default prefix and setting the pipeline route through the Additional API Routes parameter, be careful not to set an existing pipeline route used by other pipelines. In case you have more than one pipeline major version, it’s also important to keep in mind that the pipeline route versioning must be done by the user due to the absence of a versioning path parameter. For example: /pipeline/realm/v1/.

Rate Limit

When creating APIs, we usually want to limit the number of API requests users can make in a given time interval.

This action can be performed by activating the Rate Limit option and applying the following settings:

If the API has additional paths, the limit is shared among all paths. To apply the rate limit settings, the API must be configured with an API key or Basic Auth so that the Aggregate by parameter can be used by groups of credentials if the Consumer option is selected, or by an individual credential if the Credential option (API Key, Basic Auth) is selected.

If multiple interval parameters are configured with repeating values, only one of these values is considered. It’s also necessary that a value greater than zero be informed for the Limit parameter.

If the rate limiting options aren't set correctly, they'll be ignored and a warning log will be issued. You can view this log on the Pipeline Logs page.

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 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"
}

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"
}

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 content type 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>
}

Last updated