Skip to content

Instantly share code, notes, and snippets.

@rebarachel
Created May 8, 2019 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebarachel/215e3f0ac615ef8a644dbc7aa72b2af9 to your computer and use it in GitHub Desktop.
Save rebarachel/215e3f0ac615ef8a644dbc7aa72b2af9 to your computer and use it in GitHub Desktop.
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"]]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment