Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix missing mime types the Docker image. (#18246) (#18250)

Filip Owczarek83cf096b54bc
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
index 636991546c..dee93b9fa9 100644
--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -14,9 +14,10 @@ RUN apt-get update \
libwebp7 \
libpq5 \
shared-mime-info \
- libmagic1
+ libmagic1 \
+ # Required to allows to identify file types when handling file uploads
+ media-types
-WORKDIR /app
COPY --from=ghcr.io/astral-sh/uv:0.8 /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1 UV_SYSTEM_PYTHON=1 UV_PROJECT_ENVIRONMENT=/usr/local
RUN --mount=type=cache,target=/root/.cache/uv \
diff --git a/Dockerfile b/Dockerfile
index 5e0791fe2e..f7fb8fed1b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -35,7 +35,8 @@ RUN apt-get update \
libmagic1 \
# Required by celery[sqs] which uses pycurl for AWS SQS support
libcurl4 \
- shared-mime-info \
+ # Required to allows to identify file types when handling file uploads
+ media-types \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
diff --git a/saleor/graphql/core/tests/test_file_validation.py b/saleor/graphql/core/tests/test_file_validation.py
index e83e8ce563..b08a216730 100644
--- a/saleor/graphql/core/tests/test_file_validation.py
+++ b/saleor/graphql/core/tests/test_file_validation.py
@@ -11,6 +11,7 @@ from ....product.error_codes import ProductErrorCode
from ..validators.file import (
clean_image_file,
is_image_mimetype,
+ is_image_url,
is_supported_image_mimetype,
validate_image_url,
)
@@ -314,3 +315,29 @@ def test_clean_image_file_in_avif_format():
# when & then
clean_image_file({field: img}, field, ProductErrorCode)
+
+
+ ("url", "is_valid"),
+ [
+ ("http://example.com/valid_image.jpg", True),
+ ("https://example.com/valid_image.png", True),
+ ("http://example.com/valid_image.jpeg", True),
+ ("http://example.com/valid_image.gif", True),
+ ("http://example.com/valid_image.bmp", True),
+ ("http://example.com/valid_image.tiff", True),
+ ("http://example.com/valid_image.webp", True),
+ ("https://example.com/valid_image.webp", True),
+ ("http://example.com/valid_image.avif", True),
+ ("http://example.com/invalid_image.pdf", False),
+ ("http://example.com/invalid_image.docx", False),
+ ("http://example.com/invalid_image.exe", False),
+ ("http://example.com/invalid_image.txt", False),
+ ],
+)
+def test_is_image_url(url, is_valid):
+ # when
+ result = is_image_url(url)
+
+ # then
+ assert result is is_valid