From 0c10472e2ef1640f55820587c24e7b91f1e92788 Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Wed, 8 Mar 2023 15:50:40 +0100 Subject: [PATCH] Add mime types --- src/MediaData.php | 3 +++ tests/Feature/IndexTest.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/MediaData.php b/src/MediaData.php index 264b17e..1613515 100644 --- a/src/MediaData.php +++ b/src/MediaData.php @@ -27,6 +27,8 @@ class MediaData extends Data public string $fileName; + public string $mimeType; + #[MapInputName('custom_properties')] public array $properties; @@ -63,6 +65,7 @@ class MediaData extends Data 'file_name' => pathinfo($default[0], PATHINFO_BASENAME), 'properties' => [], 'fallback' => true, + 'mime_type' => Storage::disk($default[1])->mimeType($default[0]), ]); } } diff --git a/tests/Feature/IndexTest.php b/tests/Feature/IndexTest.php index 4d2977d..8d0aced 100644 --- a/tests/Feature/IndexTest.php +++ b/tests/Feature/IndexTest.php @@ -29,6 +29,7 @@ test('it gets media for single', function () { $response->assertJsonPath('id', $media->id); $response->assertJsonPath('properties.test', 'old'); $response->assertJsonPath('fallback', false); + $response->assertJsonPath('mime_type', 'application/pdf'); }); test('it checks for authorization', function () { @@ -64,6 +65,7 @@ test('test it gets conversions for single media', function () { test('test it gets default single media', function () { $this->auth()->registerModel(); $post = $this->newPost(); + Storage::disk('public')->put('default.jpg', $this->jpgFile()->getContent()); $response = $this->getJson("/mediaupload/post/{$post->id}/conversionsWithDefault"); @@ -73,4 +75,5 @@ test('test it gets default single media', function () { $response->assertJsonPath('name', 'default'); $response->assertJsonPath('file_name', 'default.jpg'); $response->assertJsonPath('fallback', true); + $response->assertJsonPath('mime_type', 'image/jpeg'); });