Skip to content

Commit ed8d40d

Browse files
[7.x] Added missing symfony/mime suggest (#33067)
* Added missing symfony/mime suggest * Update Filesystem.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 4ab68d1 commit ed8d40d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Illuminate/Filesystem/Filesystem.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use FilesystemIterator;
77
use Illuminate\Contracts\Filesystem\FileNotFoundException;
88
use Illuminate\Support\Traits\Macroable;
9+
use RuntimeException;
910
use Symfony\Component\Finder\Finder;
1011
use Symfony\Component\Mime\MimeTypes;
1112

@@ -321,6 +322,12 @@ public function extension($path)
321322
*/
322323
public function guessExtension($path)
323324
{
325+
if (! class_exists(MimeTypes::class)) {
326+
throw new RuntimeException(
327+
'To enable support for guessing extensions, please install the symfony/mime package.'
328+
);
329+
}
330+
324331
return (new MimeTypes)->getExtensions($this->mimeType($path))[0] ?? null;
325332
}
326333

src/Illuminate/Filesystem/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).",
3636
"league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).",
3737
"league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).",
38-
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0)."
38+
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
39+
"symfony/mime": "Required to enable support for guessing extensions (^5.0)."
3940
},
4041
"config": {
4142
"sort-packages": true

0 commit comments

Comments
 (0)