2012-09-11 67 views
1

我無法爲服務器文件提供用戶下載服務。我在mod_xsendfile中使用Apache。首先,如果我嘗試在開發服務器上下載該文件,則文件爲0字節。其次,如果我嘗試使用Apache服務的文件,我得到的錯誤Django:使用Apache和mod_xsendfile服務服務器文件

SuspiciousOperation:嘗試訪問*****就行document.file.path

file_name = document.file.name   
response = HttpResponse(mimetype='application/force-download') 
response['Content-Disposition'] = 'attachment; filename=%s' % smart_str(file_name) 
response['X-Sendfile'] = document.file.path 
return response 

我與配置mod_xsend否認「Xsend On」。感謝幫助

回答

2

的Python代碼看起來OJ給我,在你的Apache配置必須配置mode_xsendfile就像這個例子:

<Files *.*> 
XSendFile on 
XSendFilePath /absolute/path/to/your/files 
</Files> 

還要確保,即mod_xsendfile是否正確裝入。

+0

謝謝京諾...以前,我有XSendFile的設置,而不是我使用XSendFileAllowAbove的路徑設置。所以,繼續前進,我必須刪除mod_xsendfile並轉到一個全新的解決方案,這個解決方案更加簡單快捷。 –