Nginx/Django文件上传权限 [英] Nginx/Django File Upload Permissions
问题描述
今天我注意到,每当我通过Django网站上传文件时,文件上传的文件权限为0600,这意味着每当非root用户想要查看文件(nginx)时,系统都会显示403.
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.
据我所知,这只是今天才开始发生.我已经检查了Django设置文件中的file_upload_permissions和file_upload_directory_permissions,它们都设置为0644.
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.
我最近没有做过Linux/Django更新,所以这不应该成为原因,任何帮助将不胜感激.
I haven't done any Linux/Django updates recently so that shouldn't be the cause, any help would be greatly appreciated.
谢谢
山姆
推荐答案
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
这对于编写与Python 2-3兼容的代码也很有帮助.
This is also helpful in writing Python 2-3 compatible code.
这篇关于Nginx/Django文件上传权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!