我使用的开发模式蟒蛇manage.py runserver命令并得到应该为目录设置什么权限才能避免权限被拒绝?
IOError at /cmanager/upload/save
[Errno 13] Permission denied: u'/tmp/temp/IMG_27022014_183050.png'
当我运行chmod -R 775 "/tmp/temp/"
,它的工作原理。但是在每次关机/重新启动计算机时,自动删除/ tmp目录,因为需要手动创建它。
settings.py
CONTENT_STORAGE_PATH /tmp/temp/
控制器
if not os.path.exists(settings.CONTENT_STORAGE_PATH):
try:
os.makedirs(settings.CONTENT_STORAGE_PATH, 0644)
except OSError, e:
self.raiseException(e)
content_storage_path = os.path.join(settings.\
CONTENT_STORAGE_PATH, f.name)
with open(content_storage_path, 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
如何避免这种Permission Denied
错误。
设置权限是否好?如:os.chmod(content_storage_path, 0600)
。如果是的话应该是什么? 0775
?
注意:我要改变位置"/tmp/temp/"
到"/var/www/temp/"
在生产模式与Apache/NginX