【目的】构造接口浏览文件,下载文件
from django.utils.http import urlquote
path = 'D:/a.pdf'
file = open(path, 'rb')
response = FileResponse(file)
response['Content_type'] = "application/octet-stream"
##不加attachment是预览,不将文件下载下来
response['Content-Disposition'] = 'filename="%s"' % urlquote("aaa.pdf")
##加attachment是下载文件
response['Content-Disposition'] = 'attachment;filename="%s"' % urlquote("aaa.pdf")
return response