Rails:如何解压缩压缩的 xml 请求正文?
我有一个 Rails 3 站点,它从 iPhone 应用程序获取 xml 请求(包括文件提交)。 iPhone 应用程序压缩其 xml 请求的正文,该请求像这样传递到我的控制器(这是一个简单的请求,仅更新几个详细信息而不是发送任何文件):
params = {"\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x035\xCAA\x0E\x83 \x10@\xD1\xD3\xE8\xD20\x02R\x17\xDD4\xBD\x87\x01\x9CZ\"H\x03CHo\xDF\xB2`\xFB\xDFO\xF8\x89\x89\x06\xF9\xA81\x9D/\x1F\xEB\x96IS\xC9\x83|\xDE\xF9\x98\xBA\xE2E\xE9\xBB\xD9X.j\xC2F"=>{"\xE8\xFD\xEF\xE4\x02\xB6\x00\x1C\x18\x13\x1C\xA4\xEC\x82A"=>nil}, "\xDF\x88\xA2\xCEt\xBA}\xAA\xCE{\xA7C\x1E\x04"=>nil, "\x1AN6\x86~gw\xB4\xD7\x00\x82\xE0r\xC1\x9D\x8B\xDB\xAC\xD6uF.\xCCb%\x03\x83\xA0\xD4\x0F~\xA0o\x1F\xAE\x00\x00"=>nil, "action"=>"update", "controller"=>"reports", "id"=>"65", "format"=>"xml"}
它应该如下所示:
params = {"report"=>{"workflow_status"=>"-1", "entry_count"=>"0"}, "auth"=>{"time"=>"1310044269", "email"=>"[email protected]", "sig"=>"686062dbc27ef49baa69be77a0ba6362"}, "action"=>"update", "controller"=>"reports", "id"=>"65", "format"=>"xml"}
请注意,第一个示例不是第二个示例的压缩版本,即某些值会有所不同,但整体结构应该相同(解压缩后)。
谁能告诉我如何解压它?压缩的参数来自请求正文,在某些情况下还包括文件数据。
感谢任何建议 - 最大
I have a rails 3 site which gets xml requests (incluing file submissions) from an iphone app. The iphone app compresses the body of its xml requests, which come through to my controller like this (this is a simple one that just updates a couple of details rather than sends any files):
params = {"\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x035\xCAA\x0E\x83 \x10@\xD1\xD3\xE8\xD20\x02R\x17\xDD4\xBD\x87\x01\x9CZ\"H\x03CHo\xDF\xB2`\xFB\xDFO\xF8\x89\x89\x06\xF9\xA81\x9D/\x1F\xEB\x96IS\xC9\x83|\xDE\xF9\x98\xBA\xE2E\xE9\xBB\xD9X.j\xC2F"=>{"\xE8\xFD\xEF\xE4\x02\xB6\x00\x1C\x18\x13\x1C\xA4\xEC\x82A"=>nil}, "\xDF\x88\xA2\xCEt\xBA}\xAA\xCE{\xA7C\x1E\x04"=>nil, "\x1AN6\x86~gw\xB4\xD7\x00\x82\xE0r\xC1\x9D\x8B\xDB\xAC\xD6uF.\xCCb%\x03\x83\xA0\xD4\x0F~\xA0o\x1F\xAE\x00\x00"=>nil, "action"=>"update", "controller"=>"reports", "id"=>"65", "format"=>"xml"}
It should look something like this:
params = {"report"=>{"workflow_status"=>"-1", "entry_count"=>"0"}, "auth"=>{"time"=>"1310044269", "email"=>"[email protected]", "sig"=>"686062dbc27ef49baa69be77a0ba6362"}, "action"=>"update", "controller"=>"reports", "id"=>"65", "format"=>"xml"}
Note that the first example is NOT a compressed version of the second, ie some of the values will be different, but the overall structure should be the same (once it's unzipped).
Can anyone tell me how i unzip it? The zipped params come from the request body, which will also include filedata in some cases.
grateful for any advice - max
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您也许可以使用 Richard Schneeman 的回答:
这应该放在
config/environment.rb
中You may be able to use Richard Schneeman's answer:
That should go in
config/environment.rb