首页 > 解决方案 > Content-Disposition 标头 Azure HTTP 触发函数

问题描述

基本上,我试图从 HTTP 触发的 azure 函数中获取 excel 作为响应

response = func.HttpResponse(data, mimetype='application/vnd.ms-excel')
response['Content-Disposition'] = 'attachment; filename="test.xlsx"'
return response

但没有 Content -Disposition 的标题

标签: python-3.xazureazure-functionsxlsxazure-http-trigger

解决方案


请尝试使用此代码:

response = func.HttpResponse(fileContent, headers={'Content-Disposition':'attachment; filename="test.xlsx"'}, mimetype='application/vnd.ms-excel')

推荐阅读