From 405bbc1c6195f7735d920451fe18476ec4bd0054 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 25 Oct 2017 17:57:21 +0200 Subject: Improve mimetype detection for object storages Object storage instances always fall back to the content based mimetype detection, because the file name for object storage was always random due to the fact that it was temporarily storage in a generated temp file. This patch adds a check before that to make sure to use the original file name for this purpose and also remove possible other extensions like the versioning or part file extension. Signed-off-by: Morris Jobke --- tests/lib/Files/Type/DetectionTest.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php index 295b9bf9fac..1d01a96fcc0 100644 --- a/tests/lib/Files/Type/DetectionTest.php +++ b/tests/lib/Files/Type/DetectionTest.php @@ -84,6 +84,8 @@ class DetectionTest extends \Test\TestCase { $this->assertEquals('application/octet-stream', $this->detection->detectPath('..hidden')); $this->assertEquals('application/octet-stream', $this->detection->detectPath('foo')); $this->assertEquals('application/octet-stream', $this->detection->detectPath('')); + $this->assertEquals('image/png', $this->detection->detectPath('foo.png.ocTransferId123456789.part')); + $this->assertEquals('image/png', $this->detection->detectPath('foo.png.v1234567890')); } public function testDetectString() { -- cgit v1.2.3