में फ़ाइलों की सेवा नहीं करेगा मैं स्थिर फ़ाइलों को सेवा देने के लिए mod_xsendfile (v0.12) का उपयोग कर रहा हूं जहां Django उपयोगकर्ताओं और अनुमतियों के आधार पर फ़ाइलों तक पहुंच नियंत्रित कर रहा है।XSendFile Apache 2.2
मेरी 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
सफेद सूची जोड़ लिया है। किसी और को यह काम करने के लिए मिला?
यह सब कुछ मैंने पाया है कि पूरा पथ केस संवेदनशील है, भले ही आप खिड़कियों पर हों।अगर मैं लिनक्स पर था जो तुरंत मेरे पास होता, लेकिन खिड़कियों पर मैंने उन मुद्दों को त्याग दिया। ड्राइव पत्र अपरिपक्व होना चाहिए! – boatcoder