Tôi đang sử dụng mod_xsendfile (v0.12) để phân phát tệp tĩnh nơi Django đang kiểm soát quyền truy cập vào tệp dựa trên người dùng và quyền.XSendFile sẽ không phân phối các tệp trong Apache 2.2
Trong file conf của tôi, tôi có:
XSendFile On
XSendFilePath e:/documents/
<Directory e:/Documents>
Order allow,deny
Allow from all
</Directory>
Trong mã django của tôi, tôi đặt tiêu đề như vậy:
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
Và trong tập tin đăng nhập của tôi, tôi nhận được:
[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
Trong phiên bản mod_xsendfile
,
tạo ra các lỗi:
Invalid command 'XSendFileAllowAbove', perhaps misspelled or defined by a module
not included in the server configuration
tôi cho rằng đó là vì họ đã thêm XSendFilePath
danh sách trắng. Bất cứ ai khác có điều này để làm việc?
Một điều khác mà tôi phát hiện ra trong tất cả điều này là toàn bộ đường dẫn phân biệt chữ hoa chữ thường, ngay cả khi bạn đang ở trên các cửa sổ.Tôi đã được trên Linux mà có thể đã xảy ra với tôi ngay lập tức, nhưng trên cửa sổ tôi loại bỏ các vấn đề đó. THẺ DRIVE PHẢI ĐƯỢC CẬP NHẬT! – boatcoder