merge with upstream
This commit is contained in:
@@ -100,13 +100,13 @@ class FileValidator(object):
|
||||
finally:
|
||||
return content
|
||||
|
||||
def validate(self, stream, file, expected):
|
||||
def validate(self, stream, expected, file=None, extension=None):
|
||||
"""Validates the uploaded file by extension
|
||||
and content
|
||||
|
||||
Arguments;
|
||||
stream (string): File content
|
||||
file (FileObject): A file object provided from the ui
|
||||
file (FileObject): A file object provided from the ui. Used only to get the file extension.
|
||||
|
||||
"""
|
||||
|
||||
@@ -114,7 +114,8 @@ class FileValidator(object):
|
||||
file_type = self.identify_file_type(stream)
|
||||
assert file_type == expected
|
||||
validator = file_type.validator(self.values)
|
||||
extension = self.obtain_extension(file)
|
||||
if extension is None:
|
||||
extension = self.obtain_extension(file)
|
||||
file_type.valid_mapping(extension)
|
||||
return validator.validate(stream)
|
||||
except AssertionError:
|
||||
|
||||
Reference in New Issue
Block a user