From a817fb1e4ae65f70563f4fed8a614b6d25698648 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Tue, 19 Nov 2024 10:15:27 -0500 Subject: [PATCH] KPMP-5671: try different response --- Dockerfile | 2 +- app.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c692fe4..596a59a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,4 @@ COPY app.py app.py COPY requirements.txt requirements.txt RUN pip3 install -r requirements.txt RUN pip3 install -U flask-cors -CMD ["uwsgi", "--http", ":5000", "--wsgi-file", "app.py"] +CMD ["uwsgi", "--http-socket", "0.0.0.0:5000", "--socket-timeout", "600", "--processes", "4", "--threads", "2", "--wsgi-file", "app.py", "--callable", "app"] diff --git a/app.py b/app.py index f4f6044..f645708 100644 --- a/app.py +++ b/app.py @@ -8,6 +8,7 @@ import mysql.connector import logging import requests +from werkzeug.wsgi import FileWrapper import json app = Flask(__name__) @@ -128,7 +129,15 @@ def downloadFile(packageId, objectName): }] } requests.post(url, json=payload, headers={"Content-Type": "application/json"}) - return send_file(object, as_attachment=True, download_name=objectName) + file_wrapper = FileWrapper(object) + headers = { + 'Content-Disposition': 'attachment; filename="{}"'.format(objectName) + } + response = Response(file_wrapper, + mimetype='application/octet-stream', + direct_passthrough=True, + headers=headers) + return response except S3Error as err: logger.error(err) return err