简体   繁体   English

获取Ruby Net :: HTTP POST的上传进度

[英]Get upload progress for Ruby Net::HTTP POST

I've been rooting around through the net/http code and haven't quite come up with a solution for this. 我一直在浏览net / http代码,并没有为此提出解决方案。 I need to perform a multipart POST request, which I have already figured out, but it would be really nice to inject a callback periodically in the upload so I could increment a progress bar. 我需要执行一个多部分POST请求,我已经想到了,但是在上传中定期注入回调会非常好,所以我可以增加一个进度条。 Does anyone know a way to get code to execute every X number of bytes sent during an HTTP post? 有没有人知道一种方法来获取代码来执行HTTP帖子中发送的每个X字节数?

It doesn't look like you're using Rails, but I think that the easiest way to do this is from the client. 它看起来不像你正在使用Rails,但我认为最简单的方法是从客户端。

In a browser setting, you can do this either with Flash (SWFUpload) or to only provide a progress bar to new browsers using new XMLHttpRequest stuff (upload still works in older browsers... just no progress bar). 在浏览器设置中,您可以使用Flash(SWFUpload)执行此操作,或者仅使用新的XMLHttpRequest内容为新浏览器提供进度条(上载仍可在旧版浏览器中使用...只是没有进度条)。

It works a little differently than you're describing, but the difference is very small. 它与你描述的有点不同,但差别非常小。 You're talking about asking the server how much data it has actually saved. 您所说的是询问服务器实际保存了多少数据。 These methods only report how much data has been sent to the server. 这些方法仅报告已将多少数据发送到服务器。

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

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