r/rails•
jejetteaway

Creating new directories in rails on heroku?

O.k. weird (and newbiesque) question - can I create a directory in the root of my application (on the same level with "public", "app" etc.) to store uploaded files and deploy to Heroku without major issues?

Since the file system is ephemeral and it's not a "rails" directory would heroku blow it away, or would I have any permission issues or issues reading and writing files to the directory?

Would using the /tmp directory be a better idea?

I'm doing this so I don't have to leave uploaded files in the public directory (which is accessible via the web - although it's unlikely).

edit: This is to be used for temporary files only. Why I ask is using certain libraries the files are instantly garbage collected when not referenced and files are (in general) deleted when the server restarts - except in the public directory.

edit #2 (or rtfm) - from heroku

Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted. For example, this occurs any time a dyno is replaced due to application deployment and approximately once a day as part of normal dyno management.

Thanks

Posted Apr 26, 2017, 6:13 PM UTC · edited

316
Loading comments…