Ruby上的Rails Multipart请求无法使用param [:name]读取



当我们的客户端应用程序帖子(JSON和CSV文件(数据到我们的REST API(Ruby on Rails Controller上(时,数据会如下所示(前缀WebKitFormBoundaryBoundAryBOundAryBOundArybgPeunnnwhk5s(。

Parameters: {"------WebKitFormBoundaryBgpEuNnwhpVHhk5srnContent-Disposition: form-data; name"=>""file"; filename="client_trades20170313.csv"rnContent-Type: application/vnd.ms-excelrnrnTr_DATE,TRAC_CLASS,PSTATUS,RWS,STR1,SWIT2rn3/13/2017,test,D,0,0,22rn3/13/2017,FX,D,4949,6615,2379rn3/13/2017,test2,D,17,17,0rn3/13/2017,ORN,D,22,22,0rn3/13/2017,RFE,D,127,127,0rn3/13/2017,FCOME,D,191,244,1425rn3/13/2017,EWS,D,0,0,356rn3/13/2017,REPO,D,40,40,0rn3/13/2017,DUND,D,0,0,38rn3/13/2017,QAS,D,24,33,21rn3/13/2017,TEURE,D,13,24,24rn3/13/2017,WQ,D,461,478,62rn3/13/2017,FUT,D,24624,32279,2685rnrn------WebKitFormBoundaryBgpEuNnwhpVHhk5srnContent-Disposition: form-data; name="metadata"rnrn{"title":"Document Uploaded by nexen UI","description":"Upload document","name":"BTS1492089784675_bmd@red","client":"test23","rrea":"Trane","sourceSystem":"CLIENT-CSV","tradeDate":"2017-04-11","timeOfDay":"intraDay"}rn------WebKitFormBoundaryBgpEuNnwhpVHhk5s--rn"}

作为结果无法检索参数(在REST控制器上('元数据'喜欢params [:metadata]。

我是Ruby在Rails上的新手,不知道如何检索WebkitFormBoundary包围的参数。

请帮助。

代码是使用Ruby 2.x和Rails 5.x编写的。

尝试通过params[:file]访问它。例如,获取文件的内容: params[:file].read

相关内容

  • 没有找到相关文章

最新更新