python下载文件headers

from aiohttp import web
from urllib.parse import quote

r = web.Response()
# r.content_type = 'application/octet-stream'
# r.content_disposition = 'attachment;filename={}'.format('语言包.xlsx')
r.headers['content_type'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
r.headers["Cache-Control"] = "no-cache"
filename = '官网语言包{}.xlsx'.format(datetime.datetime.now().strftime('%Y%m%d %H%M%S'))
r.headers["Content-Disposition"] = "attachment;filename*=UTF-8''{}".format(quote(filename.encode('utf-8')))
r.body = sio.getvalue()
return r
posted @ 2022-03-15 18:38  奈何技术不达标  阅读(298)  评论(0编辑  收藏  举报