From 6f2f4dbf2c83bd620a1bd7d9c16ae41111f0eac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 29 Oct 2018 15:35:38 +0100 Subject: [PATCH 2/3] misc: give profile images a .jpeg extension (#27645) This makes sure nginx will serve them with a correct MIME type. --- src/authentic2/attribute_kinds.py | 2 +- tests/test_attribute_kinds.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/authentic2/attribute_kinds.py b/src/authentic2/attribute_kinds.py index eed9b621..271b74fb 100644 --- a/src/authentic2/attribute_kinds.py +++ b/src/authentic2/attribute_kinds.py @@ -125,7 +125,7 @@ def profile_image_serialize(uploadedfile): h_computation.update(chunk) hexdigest = h_computation.hexdigest() stored_file = default_storage.save( - os.path.join('profile-image', hexdigest), + os.path.join('profile-image', hexdigest + '.jpeg'), uploadedfile) return stored_file diff --git a/tests/test_attribute_kinds.py b/tests/test_attribute_kinds.py index 317ce691..50082fbb 100644 --- a/tests/test_attribute_kinds.py +++ b/tests/test_attribute_kinds.py @@ -411,6 +411,7 @@ def test_profile_image(db, app, admin, mailoutbox, media): response = form.submit() assert john().attributes.cityscape_image profile_filename = john().attributes.cityscape_image.name + assert profile_filename.endswith('.jpeg') # verify API serves absolute URL for profile images app.authorization = ('Basic', (admin.username, admin.username)) -- 2.19.1