Skip to content

Commit

Permalink
get MIME type from extension
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Jan 25, 2019
1 parent dc1f588 commit 7da3ce3
Show file tree
Hide file tree
Showing 4 changed files with 3,045 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/core/Directus/Application/CoreServicesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,11 @@ protected function getEmitter()

// NOTE: Use the user input title, tags, description and location when exists.
$recordData = ArrayUtils::defaults($recordData, ArrayUtils::pick($data, [
'type',
'title',
'tags',
'description',
'location',
]), function ($value) {
return !!$value;
});
]));

$payload->replace($recordData);
$payload->remove('data');
Expand Down
4 changes: 3 additions & 1 deletion src/core/Directus/Filesystem/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use function Directus\generate_uuid5;
use Directus\Util\DateTimeUtils;
use Directus\Util\Formatting;
use Directus\Util\MimeTypeUtils;

class Files
{
Expand Down Expand Up @@ -261,7 +262,8 @@ public function saveData($fileData, $fileName, $replace = false)
$fileData = array_merge($this->defaults, $fileData);

return [
'type' => $fileData['type'],
// The MIME type will be based on its extension, rather than its content
'type' => MimeTypeUtils::getFromFilename($fileData['filename']),
'filename' => $fileData['filename'],
'title' => $fileData['title'],
'tags' => $fileData['tags'],
Expand Down
Loading

0 comments on commit 7da3ce3

Please sign in to comment.