Skip to content
Snippets Groups Projects
Commit ae2b1ac0 authored by Brian Moe's avatar Brian Moe
Browse files

Download/mimetype for web page urls. Issue 713

parent eb494d1f
No related branches found
No related tags found
No related merge requests found
......@@ -631,8 +631,14 @@ def download(request, graceid, filename=""):
response = HttpResponseNotFound("File not readable")
elif os.path.isfile(filepath):
# get an actual file.
response = HttpResponse(open(filepath, "r"), content_type="application/octet-stream")
response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(filename)
content_type, encoding = VersionedFile.guess_mimetype(filepath)
content_type = content_type or "application/octet-stream"
# XXX encoding should probably not be ignored.
response = HttpResponse(open(filepath, "r"), content_type=content_type)
if content_type == "application/octet-stream":
response['Content-Disposition'] = 'attachment; filename=%s' % os.path.basename(filename)
if encoding is not None:
response['Content-Encoding'] = encoding
elif not filename:
# Get list of files w/urls.
rv = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment