awsgi icon indicating copy to clipboard operation
awsgi copied to clipboard

Is there any way to download a file from s3?

Open davidhua94 opened this issue 4 years ago • 0 comments

I want to implements a download feature, when user request to download, lambda will get file content from s3, then response to api gateway. Note: I want to download a binary file, eg: xxx.bin

Here is the code:

    file = s3.get_file_content(bucket_name, key)
    
    response = make_response(file['Body'].read())
    response.headers.set('Content-Type', 'application/octet-stream')
    response.headers.set(
        'Content-Disposition', 'attachment', filename='%s' % key)
    return response

But i got some error: image

davidhua94 avatar Mar 12 '21 07:03 davidhua94