我有一个 Roda/Rack 应用程序。在后处理程序中,这是我通过表单接收的enctype="multipart/form-data"
数据图像——二进制数据——也可以通过它发送,这就是它的原因multipart/form-data
我的代码:
r.body.rewind
body_params = r.body.read
它返回这个:
body_params
=>
"------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"utf8\"\r\n\r\n\xE2\x9C\x93\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"authenticity_token\"\r\n\r\n7/Q00bPqz5dKz7ktrlFMpK5mRMO/T8vwyDu1opc/3sdizUvEZrg6ECFSGUnLD4QcX3PHgj68l6k3Z9HTQE9/Jg==\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[image_temp_url]\"\r\n\r\n\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[counterfoil_name]\"\r\n\r\nName:\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[counterfoil_email]\"\r\n\r\nEmail:\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[event_name]\"\r\n\r\ndasf\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[event_date]\"\r\n\r\nfda\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[description]\"\r\n\r\n \r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[text_color]\"\r\n\r\n#000\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[border_color]\"\r\n\r\n#cf2a27\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[paper_size]\"\r\n\r\nA4\r\n------WebKitFormBoundary123ABC\r\nContent-Disposition: form-data;
name=\"model123[font]\"\r\n\r\nArial\r\n------WebKitFormBoundary123ABC--\r\n"
现在,我如何解析参数以便我可以按名称检索它们,例如body_params["model123"]["description"]
?