我正在使用mod_xsendfile(v0.12)来提供静态文件,其中Django基于用户和权限控制访问这些文件。
在我的配置文件中,我有:
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
白名单。还有其他人成功实现了吗?