Receive File over HTTP multipart request

A file can be sent as a HTTP multipart request to the endpoint in this flow. The file is stored in the /tmp folder and the data is displayed in the debug screen if it is a text file.

[{"id":"6d7ce038.9db94","type":"debug","z":"68e1dee8.5be54","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"req.files","targetType":"msg","x":370,"y":320,"wires":[]},{"id":"53f3b844.1ba4b8","type":"httpInMultipart","z":"68e1dee8.5be54","name":"Document","url":"/tririgaDoc","method":"post","fields":"[{\"name\":\"file\"}]","swaggerDoc":"","x":120,"y":320,"wires":[["6d7ce038.9db94","dd64fd92.ff79"]]},{"id":"485b2c58.12f404","type":"change","z":"68e1dee8.5be54","name":"set","rules":[{"t":"set","p":"payload","pt":"msg","to":"req.files[\"file\"][0].path","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":180,"wires":[["ae38aa75.d2c288"]]},{"id":"ae38aa75.d2c288","type":"file-buffer","z":"68e1dee8.5be54","name":"buffer","mode":"asBuffer","x":400,"y":180,"wires":[["5d48bfee.44d99"]]},{"id":"db8904bc.6ce858","type":"debug","z":"68e1dee8.5be54","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":650,"y":180,"wires":[]},{"id":"5d48bfee.44d99","type":"string","z":"68e1dee8.5be54","name":"string","methods":[],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":510,"y":100,"wires":[["db8904bc.6ce858"]]},{"id":"dd64fd92.ff79","type":"switch","z":"68e1dee8.5be54","name":"","property":"req.files.file[0].mimetype","propertyType":"msg","rules":[{"t":"eq","v":"text/plain","vt":"str"}],"checkall":"false","repair":false,"outputs":1,"x":190,"y":260,"wires":[["485b2c58.12f404"]]}]

Flow Info

Created 5 years, 11 months ago
Rating:

Owner

Actions

Rate:

Node Types

Core
  • change (x1)
  • debug (x2)
  • switch (x1)
Other

Tags

  • http
  • multipart
  • file
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option