node-red 通过 http 上传附件
node-red upload attachment over http
这让我有点头疼。 ootb HTTP请求支持HTTPPOST;非常适用于表单数据。但是我无法让它与上传本地文件(八位字节流)一起使用。有可用的示例吗?
问候,马克
在将文件传递到 http-request 节点之前,您只需要设置 content-type header。
您可以使用更改节点来执行此操作。
以下流程从磁盘读取文件,并将其上传到 URL。
[{"id":"a6e812ac.d1a3c8","type":"http request","z":"83ca60e.03443a","name":"","method":"POST","ret":"txt","url":"http://localhost:1880/file","tls":"","x":700.5,"y":406,"wires":[["1bdd769.2f63309"]]},{"id":"a72b1e78.9cadf","type":"inject","z":"83ca60e.03443a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":144.5,"y":367,"wires":[["79844828.9aad18"]]},{"id":"79844828.9aad18","type":"file in","z":"83ca60e.03443a","name":"","filename":"/opt/share/playing/opencv/crop.jpeg","format":"","x":361.5,"y":403,"wires":[["95401938.2085b8"]]},{"id":"95401938.2085b8","type":"change","z":"83ca60e.03443a","name":"","rules":[{"t":"set","p":"header","pt":"msg","to":"{\"content-type\": \"application/octet-stream\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":591.5,"y":348,"wires":[["a6e812ac.d1a3c8"]]},{"id":"1bdd769.2f63309","type":"debug","z":"83ca60e.03443a","name":"","active":true,"console":"false","complete":"false","x":836.5,"y":352,"wires":[]}]
这让我有点头疼。 ootb HTTP请求支持HTTPPOST;非常适用于表单数据。但是我无法让它与上传本地文件(八位字节流)一起使用。有可用的示例吗?
问候,马克
在将文件传递到 http-request 节点之前,您只需要设置 content-type header。
您可以使用更改节点来执行此操作。
以下流程从磁盘读取文件,并将其上传到 URL。
[{"id":"a6e812ac.d1a3c8","type":"http request","z":"83ca60e.03443a","name":"","method":"POST","ret":"txt","url":"http://localhost:1880/file","tls":"","x":700.5,"y":406,"wires":[["1bdd769.2f63309"]]},{"id":"a72b1e78.9cadf","type":"inject","z":"83ca60e.03443a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":144.5,"y":367,"wires":[["79844828.9aad18"]]},{"id":"79844828.9aad18","type":"file in","z":"83ca60e.03443a","name":"","filename":"/opt/share/playing/opencv/crop.jpeg","format":"","x":361.5,"y":403,"wires":[["95401938.2085b8"]]},{"id":"95401938.2085b8","type":"change","z":"83ca60e.03443a","name":"","rules":[{"t":"set","p":"header","pt":"msg","to":"{\"content-type\": \"application/octet-stream\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":591.5,"y":348,"wires":[["a6e812ac.d1a3c8"]]},{"id":"1bdd769.2f63309","type":"debug","z":"83ca60e.03443a","name":"","active":true,"console":"false","complete":"false","x":836.5,"y":352,"wires":[]}]