3

我们正在使用将多部分数据(文件)发回给我们的第三方 Web 服务。但它还通过 url http://ourdomain.com/theposturl?extra=good传递了一个额外的参数

带有 :filename 和 :tempfile 二进制数据的 'filename' 对象在 params[] 中

但是我们如何从 url 中获得“好”呢?

post /theposturl
  puts params.inspect    # this shows a hash with filename, 
                         # :filename and :tempfile as expected

  extra_param = ??????[:extra] # but what lets us 'read' the ?extra=good off the url

end
4

1 回答 1

10

您需要使用字符串作为哈希键。

extra_param = params["extra"]
于 2011-02-16T22:39:05.837 回答