我正在使用mod_xsendfile (v0.12) 来提供静态文件,其中 Django 根据用户和权限控制对文件的访问。
在我的 conf 文件中,我有:
XSendFile On
XSendFilePath e:/documents/
<Directory e:/Documents>
Order allow,deny
Allow from all
</Directory>
在我的 django 代码中,我将标题设置为:
assert(isinstance(filename, FieldFile))
xsendfile = filename.name
if(platform.system() == 'Windows'):
xsendfile = xsendfile.replace('\\', '/')
response = HttpResponse()
response['X-Sendfile'] = xsendfile
mimetype = mimetypes.guess_type(xsendfile)[0]
response['Content-Type'] = mimetype
response['Content-Length'] = filename.size
在我的日志文件中,我得到:
[Fri Oct 22 08:54:22 2010] [error] [client 192.168.20.34] (20023)The given path
was above the root path: xsendfile: unable to find file:
e:/Documents/3/2010-10-20/TestDocument.pdf
在这个版本中mod_xsendfile
,
XSendFileAllowAbove On
产生错误:
Invalid command 'XSendFileAllowAbove', perhaps misspelled or defined by a module
not included in the server configuration
我认为那是因为他们添加了XSendFilePath
白名单。其他人有这个工作吗?