502错误的网关内部服务器错误Lambda提供二进制文件

时间:2020-06-25 03:30:39

标签: aws-lambda serverless-framework binary-data

我正在像这样从节点获取中获取文件

module.exports.somelambdafunction = async (event, context, callback) => {
    const streamData = await fetch(some file url, {
          headers: {
            Authorization: `Bearer ${this.accessToken}`,
            'Content-Type': 'application/json',
          },
        });
    const buffer = await streamData.buffer(); 
    response.headers = {
      'Access-Control-Allow-Origin': '*',
      'Access-Control-Allow-Methods': 'GET, POST',
      'Content-Type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
      Accept: 'application/octet-stream',
      'Content-disposition': `attachment; filename=${getSpFileAttributes.LinkFilename}`,
    };
    response.body = buffer;
    response.isBase64Encoded = true;
    return response;
}

给定的缓冲区,我还将isBase64Encoded设置为true。我正在使用无服务器来部署这个东西。但是,当调用端点时,我不断收到内部服务器错误。我在这里做什么错了?

0 个答案:

没有答案