How can I pass the csv file or file stream or something in line of that to the rake task I'm running on the remote app via rake task arguments?
So I can get the contents of that file in the file and do something with it. It's not a big file.
I tried with suggestion from Luc:
desc 'Test task'
namespace :app do
task :pipe_file => [:environment] do |t, args|
File.open('my_temp_file', 'w') do |f2|
while line = STDIN.gets
cat tst.csv | bundle exec rake app:pipe_file
You can pipe the content of your file to your rake task:
cat my_file | heroku run rake my_task
Then inside your task you need to start by reading STDIN:
STDIN.binmode tmp_file = Tempfile.new('temp_file_prefix', Rails.root.join('tmp')) tmp_file.write(STDIN.read) tmp_file.close Process tmp_file here. puts tmp_file.path tmp_file.unlink
Hope it helps !