fix 500 error when file extension could not be guessed
when a file without an extension was uploaded and the mimetypes.guess_extension returned None because there is no official file extension for that mimetype a NoneType was subscripted which yielded a 500 http error
This commit is contained in:
parent
e1e99957b6
commit
3950f6e8eb
4
fhost.py
4
fhost.py
|
@ -247,8 +247,10 @@ class File(db.Model):
|
||||||
if not ext:
|
if not ext:
|
||||||
if gmime in app.config["FHOST_EXT_OVERRIDE"]:
|
if gmime in app.config["FHOST_EXT_OVERRIDE"]:
|
||||||
ext = app.config["FHOST_EXT_OVERRIDE"][gmime]
|
ext = app.config["FHOST_EXT_OVERRIDE"][gmime]
|
||||||
|
elif guess:
|
||||||
|
ext = guess
|
||||||
else:
|
else:
|
||||||
ext = guess_extension(gmime)
|
ext = ""
|
||||||
|
|
||||||
return ext[:app.config["FHOST_MAX_EXT_LENGTH"]] or ".bin"
|
return ext[:app.config["FHOST_MAX_EXT_LENGTH"]] or ".bin"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue