FileQuestion: self.value may not be an str

This commit is contained in:
Alexandre Aubin 2021-10-06 13:04:24 +02:00
parent 7425684552
commit 99d2637cfe

View file

@ -1164,9 +1164,11 @@ class FileQuestion(Question):
FileQuestion.upload_dirs += [upload_dir] FileQuestion.upload_dirs += [upload_dir]
logger.debug(f"Saving file {self.name} for file question into {file_path}") logger.debug(f"Saving file {self.name} for file question into {file_path}")
if Moulinette.interface.type != "api" or (
self.value.startswith("/") and os.path.exists(self.value) def is_file_path(s):
): return isinstance(s, str) and s.startswith("/") and os.path.exists(s)
if Moulinette.interface.type != "api" or is_file_path(self.value):
content = read_file(str(self.value), file_mode="rb") content = read_file(str(self.value), file_mode="rb")
else: else:
content = b64decode(self.value) content = b64decode(self.value)