2

Carrierwave was working perfectly, I moved the directory out of the public (for security reasons) and I got this error when I tried to upload an image:

Errno::EACCES in PostsController#create
Permission denied - /home/starkers/Desktop/carrierwave3/public/uploads

I've chown -R 777 carrierwave3 and it still gives me the error. Notice I've put the directory back inside public and it's still giving me this! I've restarted the server. Not working. I've run sudo chown -R root carrierwave3 still this permission error! Insane!

I'm running Ubuntu Saucy Salamander.

Starkers
  • 10,273
  • 21
  • 95
  • 158
  • What a foul error..this is maddening!!! – Starkers Apr 01 '14 at 01:42
  • Have you checked out http://stackoverflow.com/questions/9749451/rails-errnoeacces-permission-denied-when-uploading-avatar-for-user and http://blog.pardner.com/2012/01/rails-3-1-carrierwave-s3-heroku/ ? – Ilya I Apr 01 '14 at 03:48

1 Answers1

2

Right guys this is a really bizarre error in-case anyone every encounters this. It appears to have arisen through use of my uploader's filename method. Here was my method:

def filename
    "#{SecureRandom.base64}"
end

This results in an invalid filename (no extension), however, an unforseen effect of this is that the directory the uploads folder is in (in my case public) is made read only. So strange. A bug for sure.

The solution for me was to delete the entire public folder, comment out the filename function, recreate the public folder and upload another image through the app. Works again. Also, if my files have proper names:

def filename
    "#{SecureRandom.base64}.gif"
end

It works properly. Just a really, really strange bug.

Starkers
  • 10,273
  • 21
  • 95
  • 158