Django/文件上传权限 [英] Django / file uploads permissions
本文介绍了Django/文件上传权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一个 django 应用程序,但我对从网络表单上传文件的文件权限有一点问题.
I wrote a django app, but I have a little problem with the file permissions of the uploads files from a web form.
基本上我可以上传 .mp3 文件,但它始终保持 chmod 600.
Basically I can upload a .mp3 file but it always keep chmod 600.
容器文件夹有chmod 775,umask设置为022.
The container folder has chmod 775, and the umask is set to 022.
我使用的是共享托管服务.
I'm in a shared hosting service.
推荐答案
如果您使用 Python 2,请在您的 settings.py 中试试这个:
Try this in your settings.py if you use Python 2:
FILE_UPLOAD_PERMISSIONS = 0644
在 Python 3 中,八进制数必须以 0o 开头,所以该行是:
In Python 3 octal numbers must start with 0o so the line would be:
FILE_UPLOAD_PERMISSIONS = 0o644
有关详细信息请参阅文档.
这篇关于Django/文件上传权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文