节点红色高级多部分/表单数据文件上载

时间:2018-05-03 12:12:01

标签: file upload multipartform-data node-red

我想创建一个节点红色流,通过访问http://localhost:1880/uploadFile使用本地表单获取用户选择的本地文件,然后我想调用接受{http://localhost:8080/uploadFile的Spring引导端点userFile 1}}参数应该是使用HTML文件控件上传的file对象。

邮递员请求如下所示:

POST /uploadFile HTTP/1.1
Host: localhost:8080
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Cache-Control: no-cache
Postman-Token: 7ce4af6f-e990-414d-b7ee-da87b2459f16

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="userFile"; filename="file100.json"
Content-Type: 


------WebKitFormBoundary7MA4YWxkTrZu0gW

我创建了一个工作流程,但它无法正常工作。进入控制器的Multipart对象是null

节点红色项目是:

[{"id":"e0dd6ce3.888e4","type":"debug","z":"8fccbdb9.9ebab","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"req.files","x":450,"y":880,"wires":[]},{"id":"bdd07a9d.cc1748","type":"httpInMultipart","z":"8fccbdb9.9ebab","name":"","url":"/upload_post","method":"post","fields":"[{\"name\":\"userFile\"}]","swaggerDoc":"","x":110,"y":880,"wires":[["e0dd6ce3.888e4","f3d822c.a0300e"]]},{"id":"a3997970.3c89c8","type":"http request","z":"8fccbdb9.9ebab","name":"","method":"POST","ret":"obj","url":"http://localhost:8080/uploadFile","tls":"","x":630,"y":760,"wires":[["34e2955f.2d931a","768507e9.001da8"]]},{"id":"34e2955f.2d931a","type":"debug","z":"8fccbdb9.9ebab","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":830,"y":680,"wires":[]},{"id":"768507e9.001da8","type":"http response","z":"8fccbdb9.9ebab","name":"","statusCode":"","headers":{},"x":850,"y":760,"wires":[]},{"id":"f3d822c.a0300e","type":"function","z":"8fccbdb9.9ebab","name":"Headers","func":"msg.headers = {};\n\nmsg.headers['Content-Type']= 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW';\n//msg.headers['boundary']='----WebKitFormBoundary7MA4YWxkTrZu0gW';\nmsg.headers['Content-Disposition']='form-data; name=\"patternFile\"; filename=\"file100.json\"';\n// msg.headers['name']='patternFile';\n// msg.headers['filename']='file100.json';\n\n// return msg;\nreturn [ msg, msg.payload];","outputs":1,"noerr":0,"x":400,"y":760,"wires":[["a3997970.3c89c8"]]},{"id":"cb96168b.2e1ba8","type":"http in","z":"8fccbdb9.9ebab","name":"","url":"/upload_post1","method":"post","upload":true,"swaggerDoc":"","x":110,"y":760,"wires":[["6e5ad2f2.b0f62c","f3d822c.a0300e"]]},{"id":"6e5ad2f2.b0f62c","type":"debug","z":"8fccbdb9.9ebab","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"req.files","x":410,"y":640,"wires":[]}]

1 个答案:

答案 0 :(得分:-1)

您是否尝试按Body > Binary > Choose Files?

上传文件

欢迎您查看此解决方案: https://github.com/postmanlabs/postman-app-support/issues/3331