从 HTTP 响应 NodeRed 下载文件
Download file from HTTP response NodeRed
在 Node-Red 中,我试图调用一个 API,它为我提供了一个充满数据的 csv 文件,我发出了一个 http 请求并得到以下 return:
{
"_msgid": "60d0351dcf215557",
"payload": "",
"topic": "",
"headers": {
"content-length": "0",
"connection": "close",
"content-type": "text/csv",
"date": "Fri, 13 May 2022 07:48:51 GMT",
"server": "Microsoft-IIS/10.0",
"access-control-expose-headers": "Request-Context",
"cache-control": "no-cache",
"expires": "-1",
"pragma": "no-cache",
"request-context": "",
"x-frame-options": "DENY",
"content-disposition": "attachment; filename=Report_20180520_0000_20180720_2359.csv",
"x-node-red-request-node": "3a8a1b06"
},
"statusCode": 200,
"responseUrl": "https://somewebsite.net/api/analytics/report/someID/file",
"redirectList": [],
"retry": 0,
"url": "https://somewebsite.net/api/analytics/report/someID/file"
我的问题是,如何真正下载 Report_20180520_0000_20180720_2359.csv?
感谢您的帮助。
文件内容会在 msg.payload
中,但查看该响应时服务器返回的文件是空的。
可以看出msg.payload
为空,msg.headers.content-length
为0
在 Node-Red 中,我试图调用一个 API,它为我提供了一个充满数据的 csv 文件,我发出了一个 http 请求并得到以下 return:
{
"_msgid": "60d0351dcf215557",
"payload": "",
"topic": "",
"headers": {
"content-length": "0",
"connection": "close",
"content-type": "text/csv",
"date": "Fri, 13 May 2022 07:48:51 GMT",
"server": "Microsoft-IIS/10.0",
"access-control-expose-headers": "Request-Context",
"cache-control": "no-cache",
"expires": "-1",
"pragma": "no-cache",
"request-context": "",
"x-frame-options": "DENY",
"content-disposition": "attachment; filename=Report_20180520_0000_20180720_2359.csv",
"x-node-red-request-node": "3a8a1b06"
},
"statusCode": 200,
"responseUrl": "https://somewebsite.net/api/analytics/report/someID/file",
"redirectList": [],
"retry": 0,
"url": "https://somewebsite.net/api/analytics/report/someID/file"
我的问题是,如何真正下载 Report_20180520_0000_20180720_2359.csv? 感谢您的帮助。
文件内容会在 msg.payload
中,但查看该响应时服务器返回的文件是空的。
可以看出msg.payload
为空,msg.headers.content-length
为0