Skip to content

[Mime] Add the component #29896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[HttpFoundation] updated File code
  • Loading branch information
fabpot committed Jan 16, 2019
commit d7ee0ecc491bd45425ff3a5223c51a8ef200fee8
15 changes: 5 additions & 10 deletions src/Symfony/Component/HttpFoundation/File/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,23 @@ public function __construct(string $path, bool $checkPath = true)
*/
public function guessExtension()
{
$type = $this->getMimeType();
$guesser = ExtensionGuesser::getInstance();

return $guesser->guess($type);
return ExtensionGuesser::getInstance()->guess($this->getMimeType());
}

/**
* Returns the mime type of the file.
*
* The mime type is guessed using a MimeTypeGuesser instance, which uses finfo(),
* mime_content_type() and the system binary "file" (in this order), depending on
* which of those are available.
* The mime type is guessed using a MimeTypeGuesserInterface instance,
* which uses finfo_file() then the "file" system binary,
* depending on which of those are available.
*
* @return string|null The guessed mime type (e.g. "application/pdf")
*
* @see MimeTypeGuesser
*/
public function getMimeType()
{
$guesser = MimeTypeGuesser::getInstance();

return $guesser->guess($this->getPathname());
return MimeTypeGuesser::getInstance()->guess($this->getPathname());
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Component/HttpFoundation/File/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,7 @@ public function getClientMimeType()
*/
public function guessClientExtension()
{
$type = $this->getClientMimeType();
$guesser = ExtensionGuesser::getInstance();

return $guesser->guess($type);
return ExtensionGuesser::getInstance()->guess($this->getClientMimeType());
}

/**
Expand Down