Nginx/Django文件上传权限 [英] Nginx/Django File Upload Permissions

查看:311
本文介绍了Nginx/Django文件上传权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我注意到,每当我通过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.

谢谢

山姆

推荐答案

如果您最近使用了Python 3,请查看

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆