• Docs
  • Home

›HTTP Endpoints

Messages

  • Set Property Fixed
  • Delete Message Property
  • Move Property
  • Map Range

Data Formats

  • Convert to/from JSON
  • Convert to/from XML
  • Convert to/from YAML
  • Generate CSV output
  • Parse CSV input
  • Simple GET request
  • Split text

Flow Control

  • Trigger On Start
  • Trigger At Interval
  • Trigger At Time
  • Route On Property
  • Route On Context
  • Operate On Array
  • Trigger Timeout
  • Trigger Placeholder
  • Rate Limit Messages
  • Rate Limit Message Stream
  • Report By Exception
  • Join Streams

Error handling

  • Retry On Error
  • Trigger On Error

HTTP Endpoints

  • Create Endpoint
  • Handle Query Parameters
  • Handle Url Parameters
  • Access Headers
  • Serve JSON
  • Serve Local File
  • Post Data
  • Post Form Data
  • Post JSON
  • Cookies

HTTP Requests

  • GET Request
  • Set URL
  • Set URL using Template
  • Set Query String
  • Parse JSON
  • Binary Response
  • Set Request Header

MQTT

  • MQTT broker
  • Publish Message
  • Set the topic
  • Publish Retained Message
  • Subscribe to a topic
  • Receive a parsed JSON message

OData

  • Define a Metadata Model
  • Define Metadata Model using EDM
  • Convert Request to Query
  • Read Only OData Service
  • Create an OData Service

Sequelize

  • Execute a Query

Auth

  • Basic Authentication
  • Generate JWT
  • Verify JWT

JSONata

  • JSONata Node
  • JSONata Explorer

Breakpoint

  • Introduction
  • How to Use

OpenAPI

  • Introduction
  • OpenAPI Router
  • OpenAPI Client

Release Management

  • Upload Download Release Management

Designer

  • Designer

Monitor

  • Introduction
  • How To Use

CI/CD

  • Introduction
  • Installation

Serve a local file

Problem

You want to create an HTTP endpoint that responds to GET requests with content from a local file, such an png image.

Solution

Use the File In node to load the required content and set the Content-Type to the appropriate value for the file type being returned.

Example

Flow JSON

[{"id":"c7e341a0.381cc","type":"http in","z":"3045204d.cfbae","name":"","url":"/hello-file","method":"get","swaggerDoc":"","x":110,"y":720,"wires":[["2fb1c354.d04e3c"]]},{"id":"2fb1c354.d04e3c","type":"file in","z":"3045204d.cfbae","name":"","filename":"/tmp/Ignite.png","format":"","x":290,"y":720,"wires":[["c9e28681.361d78"]]},{"id":"c9e28681.361d78","type":"change","z":"3045204d.cfbae","name":"Set Headers","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.content-type","pt":"msg","to":"image/png","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":720,"wires":[["88974243.7768c"]]},{"id":"88974243.7768c","type":"http response","z":"3045204d.cfbae","name":"","x":610,"y":720,"wires":[]}]
[~]$ curl  https://app_name.herokuapp.com/hello-file > file.png

Discussion

When loading a non-text file such as an image, the File In node must be configured to return a Buffer object.

So that the receiver knows how to handle the file, the Content-Type header must be set to the appropriate mime type. The example above, which returns a .png file sets the Content-Type header to image/png.

← Serve JSONPost Data →
  • Problem
  • Solution
  • Example
  • Discussion
Copyright © 2021 Cyber Group