Beispiel #1
0
 def _validate_allowed_types(self):
     allowed_extensions = self._config.get("ALLOWED_IMAGES_EXTENSIONS")
     exc = BadRequest()
     exc.details = "The uploaded image extension is not allowed. Only {} extensions are allowed".format(
         ",".join(allowed_extensions)
     )
     if not self._image_obj.mimetype:
         raise exc
     image_extension = self._image_obj.mimetype.split("/")[1]
     if image_extension.lower() not in allowed_extensions:
         raise exc
Beispiel #2
0
 def _validate_not_none(self):
     if self._image_obj is None or not self._image_obj.filename:
         exc = BadRequest()
         exc.details = "The request doesn't contain uploaded file"
         raise exc