From a3b3df1bbb878a841add7cc801a84361c978116c Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Tue, 7 Sep 2021 12:09:30 -0400 Subject: [PATCH] Use flask send_file to return DMN file --- crc/api/file.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crc/api/file.py b/crc/api/file.py index be071ba5..5e8c3889 100644 --- a/crc/api/file.py +++ b/crc/api/file.py @@ -1,4 +1,5 @@ import io +from datetime import datetime from typing import List import connexion @@ -176,4 +177,10 @@ def delete_file(file_id): def dmn_from_ss(): file = connexion.request.files['file'] result = FileService.dmn_from_spreadsheet(file) - return result + return send_file( + io.BytesIO(result), + attachment_filename='temp_dmn.dmn', + mimetype='text/xml', + cache_timeout=-1, # Don't cache these files on the browser. + last_modified=datetime.now() + )