通过 HTTPS 上传文件 - 桌面到 Web 服务器
我有一个桌面应用程序需要将文件上传到网络服务器。
协议是HTTPS。
我想我应该写一个 ashx 来处理上传; 一次发送 4k 块。 每次都得到“ok”的响应。 这是一个好的算法吗?
通过 HTTPS 从桌面应用程序上传到网络服务器的最佳算法是什么?
I have a desktop application that needs to upload files to a webserver.
The protocol is HTTPS.
I'm thinking I should write an ashx that will handle the uploads; sending 4k chunks at a time. With a response of ok each time. Is this a good algorithm?
What is the best algorithm for uploading from a desktop application to a webserver over HTTPS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您要上传多大的文件? 只要它们不是很大(> 100 MB),您就可以生成分段 MIME 编码上传(RFC 1867)来自您的应用程序。 这与浏览器用于上传的格式相同,因此您的处理程序只需从 Request.Files 集合中提取文件。 除非您在慢速连接上上传或上传大文件,否则分块不会给您带来太多帮助。
How large of files are you looking to upload? As long as they're not huge (> 100 MB), you could generate a multipart MIME encoded upload (RFC 1867) from your application. This is the same format browsers use for uploads, so your handler would just pull the file from the Request.Files collection. Chunking isn't going to get you much unless you're uploading on a slow connection or uploading huge files.
如果您采用仅在收到前一个数据包的确认后才发送下一个数据包的简单方法,则分块可能会减慢您的速度。 事实证明,这种方法很慢(在具有不小的延迟的网络上)。 尝试一些由网络服务器直接支持的东西,而不是自己动手(例如 Chris Hynes 提出的建议:多部分 MIME 编码上传)。
Chunking is likely to slow you down if you take the simplistic approach of sending the next packet only after the acknowledgement of the previous packet is received. This approach has proven to be slow (over networks with nontrivial latency). Try something that's directly supported by the webserver rather than rolling your own (such as the suggestion made by Chris Hynes: multipart MIME encoded upload).