在我的sinatra應用程序中,我正在使用以下curl
命令在路由/test
中發佈文件。如何從CURL參數中讀取文件數據?
curl -H "Content-Type: text/xml" -vv -X POST -d [email protected]
http://localhost:4567/test
在我屈POST方法我要讀文件中像
post '/test' do
data = params[:file_data] #Here file_data param name of CURL command.
end
但是,在這裏data
是NULL
。我應該如何配置我的CURL命令來讀取file_data
param中的文件?
你應該使用'--data-binary @ test.xml' - 檢查出來http://curl.haxx.se/docs/manpage.html#--data-binary – 2014-09-29 06:14:05
@PamioSolanky,不起作用。我仍然無法從file_data參數中讀取文件。 – Masudul 2014-09-29 06:18:45
如果你只想'POST'這個文件,那麼你可以用'curl -H'Content-Type:text/xml「-i -F name = test -F [email protected] http:// localhost :4567/test' – 2014-09-29 07:57:11