我可以强制 Rails 会话从字符串重新加载吗?
我有一个与 Rails 2.3.3 一起使用的第三方应用程序(上传进度条 - swfupload),无法传递会话信息或 cookie。 不过,我可以将应用程序中的会话数据打包到 URI 中,它将用于上传文件并在获取文件时检索该文件。
问题是,我在网络上看到的所有神奇的 hack 都不能与 2.3.3 一起工作。 我不知道具体原因,但我什至尝试过使用 swfupload 的最小 RESTful 演示应用程序,它的呕吐方式与我的一样。
我所需要的只是一种强制从已知包含会话数据的字符串重新加载会话的方法。 大概是这样的:
if session[:user_id]
do stuff
else
session.reload(session_string_from_uri)
end
你明白了。
不,我对尝试另一个 Rails 上传器解决方案不感兴趣。 我已经经历了足够多的失败,所以我将坚持使用这个解决方案,因为对我当前问题的简单回答将解决我的问题。
I have a third-party app (an upload progress bar - swfupload) that I'm using with rails 2.3.3 that cannot pass along session information or cookies. I can, however, pack the session data from my app into the URI it will use to upload a file and retrieve that when I get the file.
The trouble is, none of the magic hacks I see floating around the net work with 2.3.3. I don't know the specific details of why, but I've even tried the minimal RESTful demo application that uses swfupload and it pukes the same way mine does.
All I need is a way to force a reload of the session from a string, known to contain session data. Something along the lines of:
if session[:user_id]
do stuff
else
session.reload(session_string_from_uri)
end
You get the idea.
No, I'm not interested in trying yet another uploader solution for Rails. I've had enough of them fail that I'm going to stick with this solution because a simple answer to my current question will solve my problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用机架中间件从随 Flash 请求一起发布的数据中恢复会话。 这是一篇很好的文章,解释了这一点: http://jetpackweb.com/blog/2009/10/21/rails-2-3-4-and-swfupload- rack-middleware-for-flash-uploads-that-degrade-graceively/comment-page-1/
You need to use a rack middleware to restore the session from data posted along with the Flash request. Here is a very good article explaining this: http://jetpackweb.com/blog/2009/10/21/rails-2-3-4-and-swfupload-rack-middleware-for-flash-uploads-that-degrade-gracefully/comment-page-1/
不确定这是否适合您,但我的 swfuploader 修复很简单,因为我们有数据库会话。
Not sure if this is an option for you, but my swfuploader fix was easy because we have DB sessions.