mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-25 19:50:49 -04:00
Fix 500 being thrown when uploading large files
This is re-fixing a bug which was re-introduced when adding the `Spreadsheet` class in1409ca36ca. It was previously fixed in19662d8329: > 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:
@@ -158,7 +158,7 @@ class Spreadsheet():
|
||||
|
||||
@staticmethod
|
||||
def normalise_newlines(file_content):
|
||||
return '\r\n'.join(file_content.getvalue().decode('utf-8').splitlines())
|
||||
return '\r\n'.join(file_content.read().decode('utf-8').splitlines())
|
||||
|
||||
@classmethod
|
||||
def from_rows(cls, rows, filename=''):
|
||||
|
||||
Reference in New Issue
Block a user