Fix bug with large file uploads

Depending on the size of the uploaded file, Flask will temporarily store
it in different ways. This means that it comes back as a `TempFile` if
the file is roughly <500k and as `BytesIO` if the file is larger.

`TempFile` supports the `.getvalue()` method, but `BytesIO` does not.
Both support the `.read()` method, so this commit changes to use that
instead.
This commit is contained in:
Chris Hill-Scott
2016-04-25 09:26:25 +01:00
parent 7b540fe10b
commit 19662d8329

View File

@@ -110,7 +110,7 @@ def send_messages(service_id, template_id):
service_id,
{
'file_name': form.file.data.filename,
'data': form.file.data.getvalue().decode('utf-8')
'data': form.file.data.read().decode('utf-8')
},
current_app.config['AWS_REGION']
)