我是否需要 Rack 中间件来通过 HTML5 进行文件上传(文件 API + XMLHttpRequest Level 2)
我想为 Rails 应用程序构建一个带有进度指示器的(多)文件上传。此外,我不想使用基于 Flash 的解决方案。
我发现了许多 jQuery 库(例如 https://github.com/blueimp/jQuery- File-Upload),实现文件 API 和 XMLHttpRequest Level 2 API 以进行 Ajax 文件上传。
我想知道的是我是否需要一些额外的 Rack 中间件,正如本文末尾所声明的那样: http://blog.new-bamboo.co.uk/2010/7/30/html5-powered-ajax-file-uploads
我已经尝试过单文件ajax文件了使用 blueimp 库加载,一切似乎都很顺利,无需任何 Rack 中间件。所以我的问题是,为什么会这样?什么场景下需要中间件?
谢谢!
I'd like to build a (multi) file upload with progress indicator for a Rails app. Moreover I do not want to use a Flash based solution.
I've found a number of jQuery libraries (e.g. https://github.com/blueimp/jQuery-File-Upload) that implement the File API and XMLHttpRequest Level 2 API to have Ajax file uploads.
What I am wondering about is whether I need some extra Rack middleware, as appears to be claimed at the end of this article: http://blog.new-bamboo.co.uk/2010/7/30/html5-powered-ajax-file-uploads
I've already tried the single file ajax file up load using the blueimp library and all appears to go well, without any Rack middleware. So my question is, why is that? And in which scenario do I need the middleware?
Thnx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因是,对于不支持 formdata API 的浏览器,您需要机架中间件,因为在这种情况下,原始文件 API 流将发送到服务器。但是当使用formdata API时,你得到的是正常的文件上传数据。更多信息可以在这里找到: http://blog.new-bamboo.co.uk/2012/01/10/ridiculously-simple-ajax-uploads-with-formdata
The reason is that you need the rack middleware for browsers that do not support the formdata API, because in that case the raw file API stream is sent to the server. But when using the formdata API, you get the normal file upload data. More info can be found here: http://blog.new-bamboo.co.uk/2012/01/10/ridiculously-simple-ajax-uploads-with-formdata