1

I see everywhere that heroku deletes changes you made to the filesystem once you deploy or scale your application but in my case it seems files disappear immediately.

My rails application uploads files to public/uploads and then a delayed job tries to read those files, when it tries to read them they are not found.

If I do everything in the same thread it works, but when I try to use the delayed job or check the filesystem using heroku run bash the files are gone.

Why this happens?

Cœur
  • 37,241
  • 25
  • 195
  • 267
johnblanco
  • 197
  • 2
  • 12
  • If I'm not wrong, files uploaded to heroku don't even get created on the heroku server. It's like you sent them to a sink-hole. :-D – rkamun1 Jun 05 '15 at 18:16
  • I thought that, but if that is the case, how the hell it worked in the single thread version? My code was doing File.open("public/uploads/file","r") and it was working just fine in that scenario. – johnblanco Jun 05 '15 at 18:31
  • I guess they delete files after each request is terminated – johnblanco Jun 05 '15 at 18:32
  • ah! Here's your answer....apparently they get deleted on restart, redeploy, after the server awakes from sleep, etc etc http://stackoverflow.com/questions/11246736/after-git-push-heroku-uploaded-files-on-heroku-are-lost – rkamun1 Jun 05 '15 at 18:49
  • Have a look at: http://stackoverflow.com/questions/30408123/the-mystical-ephemeral-file-system-of-heroku-is-not-letting-me-get-files-from-s3/30408383#30408383. Note that DelayedJob is also running in its own dyno. – matt Jun 05 '15 at 19:14

1 Answers1

2

heroku is a read only file system. so actually you don't even write the files but just keep them in memory while in one thread.

if you want to use some free storage system i recommend google drive. you'll need to do some searching of how to use that since not too long ago they changed they're login policy only with Oauth, no more password/username login

cristi_razvi
  • 764
  • 1
  • 6
  • 16