I am trying to send a file to a controller action via curl.
Here is what I tried:
curl -F "file=wb.csv" http://localhost:3000/api/v1/process_data?api_key=Dp9Kv7j1y-FYytd-tYsAsSNic3ox
However, in my controller, I checked the content of the params sent and it just returns the filename wb.csv instead of a csv attachment:
{"file"=>"wb.csv", "api_key"=>"Dp9Kv7j1y-FYytd-tYsAsSNic3ox", "format"=>"json", "action"=>"import_csv", "controller"=>"api/v1/growth_utils"}
I'd like to achieve the same thing as if I was posting from a form on the UI:
<%= form_tag import_csv_admin_growths_path, multipart: true do %>
<%= file_field_tag :file %>
<%= submit_tag "Import" %>
<%end%>
Which in the controller action has params:
{"file"=>
#<ActionDispatch::Http::UploadedFile:0x007faa0543b7d0
@content_type="text/csv",
@headers="Content-Disposition: form-data; name=\"file\"; filename=\"wb.csv\"\r\nContent-Type: text/csv\r\n",
@original_filename="wb.csv",
@tempfile=#<File:/var/folders/zq/kk1mrjjn52zdf8120c4z4tb80000gn/T/RackMultipart20180405-21787-17k4lup>>,
"commit"=>"Import",
"format"=>"csv",
"action"=>"import_csv",
"controller"=>"admin/growths"}