且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AWS Lambda无法返回PDF文件

更新时间:2023-02-01 17:28:43

好,我找到了答案. 我的响应对象中的设置很好,我只需要手动更改

well, I found the answer. The settings in my response object are fine, I just had to manually change the settings in API Gateway for this to work in the browser. I have added "*/*" to binary media types under the binary settings in API Gateway console

API网关

  1. 只需登录您的控制台
  2. 选择您的api
  3. 单击下拉列表中的二进制支持
  4. 编辑二进制媒体类型并添加"*/*"

前锋

在新标签页中打开api网址(target ="_ blank").可能是浏览器正在处理已编码的base 64响应,就我而言,对于chrome,浏览器只是在新标签页中打开pdf文件,就像我想要的那样.

opening the api url in new tab (target="_blank"). Probably the browser is handling the encoded base 64 response, In my case with chrome, the browser just opens the pdf in a new tab exactly like I want it to do.