我们正在使用第三方网络服务将多部分数据(文件)发送回给我们。但它还通过 url http://ourdomain.com/theposturl?extra=good 传递额外的参数
带有 :filename 和 :tempfile 的二进制数据的“filename”对象位于 params[] 中
但是我们如何从网址中得到“好”的信息呢?
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
最佳答案
您需要使用字符串作为哈希键。
extra_param = params["extra"]
关于sinatra - Sinantra,如何在 POST 处理程序中访问 URL 参数,例如 "?something=xyz"(它不在 params[] 中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5022030/