mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Use Filesystem::getMimeType() instead of file
Summary: The `file` binary doesn't exist everywhere, use the more flexible wrapper introduce in D1609. Test Plan: Uploaded a file via drag-and-drop, it got MIME'd correctly. Reviewers: btrahan, davidreuss, Koolvin Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T869 Differential Revision: https://secure.phabricator.com/D1615
This commit is contained in:
parent
35c5852d3f
commit
6e48bfcb0a
2 changed files with 3 additions and 9 deletions
|
@ -149,14 +149,9 @@ class PhabricatorFile extends PhabricatorFileDAO {
|
|||
if (isset($params['mime-type'])) {
|
||||
$file->setMimeType($params['mime-type']);
|
||||
} else {
|
||||
try {
|
||||
$tmp = new TempFile();
|
||||
Filesystem::writeFile($tmp, $data);
|
||||
list($stdout) = execx('file -b --mime %s', $tmp);
|
||||
$file->setMimeType($stdout);
|
||||
} catch (Exception $ex) {
|
||||
// Be robust here since we don't really care that much about mime types.
|
||||
}
|
||||
$tmp = new TempFile();
|
||||
Filesystem::writeFile($tmp, $data);
|
||||
$file->setMimeType(Filesystem::getMimeType($tmp));
|
||||
}
|
||||
|
||||
$file->save();
|
||||
|
|
|
@ -15,7 +15,6 @@ phutil_require_module('phabricator', 'infrastructure/env');
|
|||
phutil_require_module('phutil', 'error');
|
||||
phutil_require_module('phutil', 'filesystem');
|
||||
phutil_require_module('phutil', 'filesystem/tempfile');
|
||||
phutil_require_module('phutil', 'future/exec');
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'parser/uri');
|
||||
phutil_require_module('phutil', 'symbols');
|
||||
|
|
Loading…
Reference in a new issue