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 的标题

解决方法

请尝试使用此代码:

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