Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Editor.browser: go through the various mime detectors while the resul…
Browse files Browse the repository at this point in the history
…t is octet-stream. Office docs should have the correct mimetype.
  • Loading branch information
cdujeu committed Oct 23, 2013
1 parent ac33f74 commit 6f40a2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/plugins/editor.browser/class.FileMimeSender.php
Expand Up @@ -62,18 +62,19 @@ public function switchAction($action, $httpVars, $filesVars)

$filesize = filesize($destStreamURL . $file);
$fp = fopen($destStreamURL . $file, "rb");
$fileMime = "application/octet-stream";

//Get mimetype with fileinfo PECL extension
if (class_exists("finfo")) {
$finfo = new finfo(FILEINFO_MIME);
$fileMime = $finfo->buffer(fread($fp, 100));
}
//Get mimetype with (deprecated) mime_content_type
elseif (function_exists("mime_content_type")) {
if (strpos($fileMime, "application/octet-stream")===0 && function_exists("mime_content_type")) {
$fileMime = @mime_content_type($fp);
}
//Guess mimetype based on file extension
else {
if(strpos($fileMime, "application/octet-stream")===0 ) {
$fileExt = substr(strrchr(basename($file), '.'), 1);
if(empty($fileExt))
$fileMime = "application/octet-stream";
Expand Down
3 changes: 3 additions & 0 deletions core/src/plugins/editor.browser/resources/other/mime.types
Expand Up @@ -56,6 +56,9 @@ application/vnd.oasis.opendocument.text odt
application/vnd.oasis.opendocument.text-master odm
application/vnd.oasis.opendocument.text-template ott
application/vnd.oasis.opendocument.text-web oth
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.palm pdb
application/vnd.rn-realmedia
application/vnd.rn-realmedia rm
Expand Down

0 comments on commit 6f40a2c

Please sign in to comment.