Skip to content

Commit

Permalink
Ignore invalid mime type detection issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Nov 8, 2019
1 parent 608c2be commit 04c0bbd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `flare-client-php` will be documented in this file

## 1.1.2 - 2019-11-08

- Ignore invalid mime type detection issues

## 1.1.1 - 2019-10-07

- Wrap filesize detection in try-catch block
Expand Down
9 changes: 8 additions & 1 deletion src/Context/RequestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Facade\FlareClient\Context;

use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Throwable;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\File\UploadedFile;
Expand Down Expand Up @@ -53,10 +54,16 @@ protected function mapFiles(array $files)
$fileSize = 0;
}

try {
$mimeType = $file->getMimeType();
} catch (InvalidArgumentException $e) {
$mimeType = 'undefined';
}

return [
'pathname' => $file->getPathname(),
'size' => $fileSize,
'mimeType' => $file->getMimeType(),
'mimeType' => $mimeType,
];
}, $files);
}
Expand Down

0 comments on commit 04c0bbd

Please sign in to comment.