Nginx/Django File Upload Permissions

徘徊边缘 提交于 2020-01-23 01:39:12

问题


Today I noticed that whenever I upload a file through my Django site the file is uploaded with the file permissions 0600 meaning whenever a non root user wants to view the file (nginx) a 403 is shown.

This only started happening today from what I can tell. I have checked both the file_upload_permissions and file_upload_directory_permissions in the Django settings file and they are both set to 0644.

I haven't done any Linux/Django updates recently so that shouldn't be the cause, any help would be greatly appreciated.

Thanks,

Sam


回答1:


If you have recently switched to Python 3, please take a look at here for a reference to octal literals in Python 3. Changing your settings as follows should fix it:

FILE_UPLOAD_PERMISSIONS = 0o644

This is also helpful in writing Python 2-3 compatible code.



来源:https://stackoverflow.com/questions/44570808/nginx-django-file-upload-permissions

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