Commit f544d94a authored by jfriedli's avatar jfriedli

Content disposition header

parent c36fc9c2
Pipeline #27732 passed with stages
in 3 minutes and 43 seconds
......@@ -50,7 +50,7 @@ def create_app(test_config=None):
def remove_file(response):
os.remove(complete_path)
return response
return send_from_directory(app.config['UPLOAD_FOLDER'], filepath)
return send_from_directory(app.config['UPLOAD_FOLDER'], filepath, as_attachment=True)
@app.route('/', methods=['GET', 'POST'])
def upload_file():
......@@ -180,7 +180,7 @@ def create_app(test_config=None):
os.remove(complete_path)
return response
return send_from_directory(app.config['UPLOAD_FOLDER'], filepath)
return send_from_directory(app.config['UPLOAD_FOLDER'], filepath, as_attachment=True)
class APIBulkDownloadCreator(Resource):
schema = {
......
......@@ -157,6 +157,7 @@ class Mat2APITestCase(unittest.TestCase):
request = self.app.get(data['download_link'])
self.assertEqual(request.status_code, 200)
self.assertIn('attachment; filename=test_name.cleaned.jpg', request.headers['Content-Disposition'])
request = self.app.get(data['download_link'])
self.assertEqual(request.status_code, 404)
......@@ -219,6 +220,7 @@ class Mat2APITestCase(unittest.TestCase):
self.assertEqual(request.headers['Content-Length'], '1596')
request = self.app.get(response['download_link'])
self.assertIn('attachment; filename=files.', request.headers['Content-Disposition'])
zip_response = zipfile.ZipFile(BytesIO(request.data))
self.assertEquals(2, len(zip_response.namelist()))
for name in zip_response.namelist():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment