我使用的開發模式蟒蛇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