Errno::EPERM (Operation not permitted FILE_PATH) when uploading image with Rails, Carrierwave, Amazon EC2

放肆的年华 提交于 2019-12-24 10:57:09

问题


I am getting an error in production that is preventing me from uploading an image to Amazon EC2 using Rails and Carrierwave.

The application works perfectly on my local development server, but in production I am getting this error

Completed 500 Internal Server Error in 6319ms

Errno::EPERM (Operation not permitted - /FILE/PATH/TO/IMAGE/DESTINATION):

I checked to make sure that the destination file has all the correct permissions. It is the upload directory, which I made sure that the entire directory was readable, writable and executable by anyone.

 ** [] lrwxrwxrwx.  1 foo rvm   50 Oct  3 10:53 uploads

Anyone know whats going on?


回答1:


This was caused by a permissions issue. Our rails app uses Amazon EC2, Capistrano for deployment and multistage extension for production and staging environments.

Before we moved to multistage extension one of the contributors owned the entire rails app, lets call him "foo". Once we implemented multistage, we decided to move the entire app to use a global user called "appuser". The problem is that many of the uploads were still owned by foo. This was causing write issues.

Changing ownership of all uploads to the proper user and group fixed the issue.




回答2:


Have you checked the permissions of carrierwave's cache_path? By default it's public/uploads/tmp/.

Have you checked carrierwave's config.permissions and config.directory_permissions? They default to 0666 and 0777 respectively, and this may or may not be sufficient to permit uploads depending on how your server is set up.



来源:https://stackoverflow.com/questions/19173194/errnoeperm-operation-not-permitted-file-path-when-uploading-image-with-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!