c# - C# Form app:使用HttpClient从磁盘上传xml文件,NodeJS服务器:正确接收xml文件
问题描述
在我的 C# Win Form 应用程序中,我可以上传这样的 xml 文件,使用 HttpClient 非常清晰和简单:
var uri = http://localhost:3000/uploads
XmlDocument xDoc = new XmlDocument();
xDoc.Load(xml file on disk);
HttpClient client = new HttpClient();
HttpContent content = new StringContent(xDoc.InnerXml, Encoding.UTF8, "text/xml");
HttpResponseMessage result = client.PostAsync(uri, content).Result;
但是,在服务器端(在 NodeJS/Express 中),我如何接收它?我来了:
const express = require('express');
const app = express();
app.post('/uploads', async function (req, res) {
await receive_xmlfile(req.body).then ((result) => {
response(res, result);
}).catch(error => {
sendError(res);
log_exception(error, req);
});
});
在这里感觉很“迷失”。我想使用一些函数(receive_xmlfile),但首先如何获取 xml?应该在体内?感谢任何答案。
解决方案
推荐阅读
- javascript - Display emoji object to text field or textarea in React
- django - 更新 Django 模型字段时的最佳实践?这是经理课程的用途吗?
- javascript - 如何在节点 js 中从 wsdl 生成 xsd
- ios - Swift 3:如何将内容包装在具有多个标签的 tableviewcell 中?
- javascript - How to use Selectize.js to find or create a rails belongs_to association?
- python - Django 变量处理——为什么会这样?
- sql - How to get the first row values in sql server query
- .net - 使用 IP 地址而不是 localhost 时.Net Remoting 方法调用的延迟
- c - 重复分配内存而不释放它
- wordpress - 如何使用 AWS 在同一台服务器上托管网站和 Web 应用程序?