Skip to content

Commit

Permalink
Merge pull request #23 from KPMP/KPMP-5671_File_Download_Fix
Browse files Browse the repository at this point in the history
Kpmp 5671 file download fix
  • Loading branch information
rlreamy authored Nov 19, 2024
2 parents 13812d1 + a817fb1 commit 712b164
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 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 ["gunicorn", "-b", ":5000", "--timeout", "300", "app:app"]
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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ boto3
flask-cors
mysql-connector-python
requests
gunicorn
uwsgi

0 comments on commit 712b164

Please sign in to comment.