Skip to content

How to return a CSV file using power tools #1780

Closed Answered by leandrodamascena
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

Hei @mrsants, tudo bom?! 😄

Thanks for opening this thread. Powertools automatically encodes the binary content to base64 to avoid any decoding errors in the Lambda response to ApiGateway according AWS documentation.

In your case you need to configure binary media types in APIGateway and also specify the header Accept in Response object. I'm not sure what headers you're passing because I can't see all that code, but I've prepared some code here to help you out.

Lambda Code

import os
from pathlib import Path
import requests

from aws_lambda_powertools import Logger
from aws_lambda_powertools.event_handler.api_gateway import (
    APIGatewayRestResolver,
    Response,
)
from aws_lambda_power…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by heitorlessa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant