From fde2ad3f65c76f040ef5794b1ed3e852577d7059 Mon Sep 17 00:00:00 2001 From: vicholp Date: Wed, 3 Aug 2022 01:22:35 -0400 Subject: [PATCH 1/2] fix get item file of web plugin --- beetsplug/web/__init__.py | 2 +- docs/changelog.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/beetsplug/web/__init__.py b/beetsplug/web/__init__.py index 63f7f92ad1..b7baa93c1e 100644 --- a/beetsplug/web/__init__.py +++ b/beetsplug/web/__init__.py @@ -324,7 +324,7 @@ def item_file(item_id): response = flask.send_file( item_path, as_attachment=True, - attachment_filename=safe_filename + download_name=safe_filename ) response.headers['Content-Length'] = os.path.getsize(item_path) return response diff --git a/docs/changelog.rst b/docs/changelog.rst index e6323393fe..31861af241 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -92,6 +92,7 @@ Bug fixes: that casues a crash when ImportAdded plugin enabled. :bug:`4389` * :doc:`plugins/convert`: Fix a bug with the `wma` format alias. +* :doc:`/plugins/web`: Fix get file from item. For packagers: From 6803ef3b83b98fdc21e42df5cacd247e14be1b90 Mon Sep 17 00:00:00 2001 From: vicholp Date: Wed, 3 Aug 2022 01:22:45 -0400 Subject: [PATCH 2/2] add test to get item file of web plugin --- test/test_web.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test_web.py b/test/test_web.py index 9a18b1dba9..3c84b14acb 100644 --- a/test/test_web.py +++ b/test/test_web.py @@ -667,6 +667,16 @@ def test_patch_item_id_readonly(self): # Remove the item self.lib.get_item(item_id).remove() + def test_get_item_file(self): + ipath = os.path.join(self.temp_dir, b'testfile2.mp3') + shutil.copy(os.path.join(_common.RSRC, b'full.mp3'), ipath) + self.assertTrue(os.path.exists(ipath)) + item_id = self.lib.add(Item.from_path(ipath)) + + response = self.client.get('/item/' + str(item_id) + '/file') + + self.assertEqual(response.status_code, 200) + def suite(): return unittest.TestLoader().loadTestsFromName(__name__)