Dyno Scp
Heroku doesnt allow you to scp a file up to their server. This gem creates a
barebones file upload mechanism that dumps a file uploaded into the public
directory. Heroku automatically cleans that directory regularly so we dont have
to worry about files lingering around.
Contents
Getting Started
Add this line to your application's Gemfile:
gem "dyno_scp", "~> <version>"
And then execute:
$ bundle
Mount the engine in your routes file:
mount DynoScp::Engine, at: "/dyno_scp"
Tips
Heroku runs processes in their own separate dynos. If you add a file in your
console session and then exit and re-enter your file will be gone. This becomes
and issue when using this tool because when you upload a file it is placed in
the web dyno which you can't directly access.
See Accessing Uploaded Files for retrieval steps.
Uploading A File
Note: The upload page requires the user to have an office:sys_admin role
After mounting the engine, you can navigate to #{host}/dyno_scp
to see the upload page.
Simply choose the file you wish to upload, then press the "upload" button. You
will see a confirmation message once the file has been uploaded.
Files are placed in the /public
folder, so use this with caution. They will
be publicly accessible to anyone who finds out they exist.
In Heroku, these files are cleared out every 24 hours automatically. In other
hosting schemes, there may not be automated cleanup of the public folder.
Accessing Uploaded Files
The main use case for this tool is to upload a file to a heroku hosted site
for usage in some type of data load or backfill task.
After setting up open a bash console on the heroku app.
heroku run bash --app my-heroku-app
To use files after they've been uploaded with this tool, you need to retreive
the file inside the bash terminal from the web dyno where it was uploaded.
Using curl
curl https://my-heroku-app.herokuapp.com/my_uploaded_file.csv -o my_uploaded_file.csv
Using wget
wget https://my-heroku-app.herokuapp.com/my_uploaded_file.csv my_uploaded_file.csv