♻️(backend) refactor uploaded file's key format

Remove the user-provided filename while preserving the extension,
and switch to the format `uuid.extension`.

This is more natural than the previous `uuid/.extension` format
and avoids confusion.

Update related tests accordingly.
This commit is contained in:
lebaudantoine
2026-03-10 20:09:20 +01:00
committed by Florent Chehab
parent 342f992556
commit f57db0acc8
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ UUID_REGEX = (
FILE_EXT_REGEX = r"[\d\w]+"
MEDIA_STORAGE_URL_PATTERN = re.compile(
f"{settings.MEDIA_URL:s}"
rf"(?P<key>{FILE_FOLDER:s}/(?P<pk>{UUID_REGEX:s})/\.{FILE_EXT_REGEX:s})$"
rf"(?P<key>{FILE_FOLDER:s}/(?P<pk>{UUID_REGEX:s})\.{FILE_EXT_REGEX:s})$"
)