简体   繁体   English

将文件放入Request.Files

[英]Getting a file into Request.Files

I have a device that uses a custom scripting language. 我有一台使用自定义脚本语言的设备。 This language provides the capability to set http request headers then perform a post to a URL. 该语言提供了以下功能:设置http请求标头,然后对URL执行发布。 The server that the device communicates with is running .net, and I would like the handler on the server to retrieve data from the device by simply pulling it from the Request.Files[] collection. 设备与之通信的服务器正在运行.net,我希望服务器上的处理程序可以通过简单地从Request.Files []集合中提取数据来从设备检索数据。 To do this, does the device need to support multipart posting or is it possible for the uploaded content to show up in the Files collection by simply setting a number of headers then sending the data? 为此,设备是否需要支持分段发布,或者是否可以通过简单地设置多个标头然后发送数据来将上传的内容显示在“文件”集合中?

I'm not a linux guy, but I did a search and I found this. 我不是Linux专家,但我进行了搜索,发现了这一点。 Does it help at all? 有帮助吗? (see section 4.3) (请参阅第4.3节)

http://curl.haxx.se/docs/httpscripting.html http://curl.haxx.se/docs/httpscripting.html

If you mean that at the server end you want the file(s) to be readable via HttpRequest.Files , then I believe so. 如果您是说在服务器端希望通过HttpRequest.Files读取文件,那么我相信是这样。

I think the format that this expects is based on the File Upload RFC and therefore if you follow the standard procedure for submitting a file upload then it'll work. 我认为这是基于文件上传RFC的格式,因此,如果您遵循提交文件上传的标准程序,那么它将起作用。

As to how you go about formatting the request from your device - I'm afraid I can't help on that one. 至于您如何格式化来自设备的请求-恐怕我对此无能为力。 Assuming you can format an Http Post, writing any headers you need and then formatting the Post body with the file content, it'll work, though. 假设您可以格式化Http Post,编写所需的任何标题,然后使用文件内容对Post正文进行格式化,就可以了。

In order for .Net to be able to read a file posted to a header it must be in the multipart posting format. 为了使.Net能够读取发布到标头的文件,它必须采用多部分发布格式。 Otherwise it will just be text noise in the header and .Net won't know what to do with it. 否则,只是标题中的文本噪音,.Net将不知道如何处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM