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