Make image upload mimetype to match frontend (#98411)

This commit is contained in:
Franck Nijhof 2023-08-15 12:26:37 +02:00 committed by GitHub
parent ed18c6a013
commit a87878f723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,8 +78,10 @@ class ImageStorageCollection(collection.DictStorageCollection):
data = self.CREATE_SCHEMA(dict(data))
uploaded_file: FileField = data["file"]
if not uploaded_file.content_type.startswith("image/"):
raise vol.Invalid("Only images are allowed")
if not uploaded_file.content_type.startswith(
("image/gif", "image/jpeg", "image/png")
):
raise vol.Invalid("Only jpeg, png, and gif images are allowed")
data[CONF_ID] = secrets.token_hex(16)
data["filesize"] = await self.hass.async_add_executor_job(self._move_data, data)