Skip to content

Commit

Permalink
KPMP-5671: try different response
Browse files Browse the repository at this point in the history
  • Loading branch information
zwright committed Nov 19, 2024
1 parent 0ebf5a7 commit a817fb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
11 changes: 10 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import mysql.connector
import logging
import requests
from werkzeug.wsgi import FileWrapper
import json

app = Flask(__name__)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a817fb1

Please sign in to comment.