如何通过文档上传器节点将.doc类型的文件上传到发现服务



在Node RED中,它有"文档上传器节点",听起来可以将文件上传到Discovery Service,但问题是我的客户端想要上传.doc文件。我当然试过了,但发现服务端将负载视为json,无法得到预期的结果。。。

  • 我将Node RED flow的json作为js片段附加,可以重现问题
  • 仅供参考,我还附上了上传结果文档上传结果

如果有人能帮我,请告诉我。。。

谢谢你,真诚的:(

[
{
"id": "e4faba0c.56b178",
"type": "watson-discovery-v1-document-loader",
"z": "638c0f19.4d555",
"name": "",
"environment_id": "170e0fd8-d7f2-4486-8bd6-6c987162961c",
"collection_id": "8c517d38-164d-415c-9137-5ff5ac08a391",
"filename": "myword.doc",
"default-endpoint": false,
"service-endpoint": "https://gateway-fra.watsonplatform.net/discovery/api",
"x": 580,
"y": 500,
"wires": [
[
"6e29e3ac.0bd18c"
]
]
},
{
"id": "f36b9a78.0eb958",
"type": "http in",
"z": "638c0f19.4d555",
"name": "[POST] interface",
"url": "/interface",
"method": "post",
"upload": true,
"swaggerDoc": "",
"x": 100,
"y": 440,
"wires": [
[
"31ec90da.b573d8",
"5220938b.ddb934"
]
]
},
{
"id": "31ec90da.b573d8",
"type": "function",
"z": "638c0f19.4d555",
"name": "reqProcessor",
"func": "msg.payload = msg.req.files[0].buffer;nnnnreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 290,
"y": 440,
"wires": [
[
"e4faba0c.56b178"
]
]
},
{
"id": "5220938b.ddb934",
"type": "debug",
"z": "638c0f19.4d555",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "req",
"x": 280,
"y": 500,
"wires": []
},
{
"id": "6e29e3ac.0bd18c",
"type": "debug",
"z": "638c0f19.4d555",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 800,
"y": 600,
"wires": []
}
]

如果它是您正在发送的真实.doc文件,那么它应该可以工作。代码正在查找.json对象或文件缓冲区。.doc文件将被视为缓冲区。我已经尝试了您的代码,并成功地将文档加载到发现中,尽管文档加载的响应实际上是在msg.document上,而不是在msg.payload上。

相关内容

  • 没有找到相关文章

最新更新