Skip to content
Snippets Groups Projects
Commit 895d29ad authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Move mimetypemapping.json to mimetypemapping.dist.json

This allows users to create their own mapping file to extend our current
mappings. This makes sure that custom mappings are not lost on OC
upgrades.
parent 35fba1ef
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
"_comment2": "The first index in the mime type array is the assumed correct mimetype", "_comment2": "The first index in the mime type array is the assumed correct mimetype",
"_comment3": "and the second (if present] is a secure alternative", "_comment3": "and the second (if present] is a secure alternative",
"_comment4": "Any changes you make here will be overwritten on an update of ownCloud",
"_comment5": "Put any custom mappings in a new file mimetypemapping.json in this directory",
"3gp": ["video/3gpp"], "3gp": ["video/3gpp"],
"7z": ["application/x-7z-compressed"], "7z": ["application/x-7z-compressed"],
......
...@@ -424,8 +424,15 @@ class OC_Helper { ...@@ -424,8 +424,15 @@ class OC_Helper {
*/ */
static public function getMimetypeDetector() { static public function getMimetypeDetector() {
if (!self::$mimetypeDetector) { if (!self::$mimetypeDetector) {
$file = file_get_contents(OC::$SERVERROOT . '/config/mimetypemapping.json'); $dist = file_get_contents(OC::$SERVERROOT . '/config/mimetypemapping.dist.json');
$mimetypemapping = get_object_vars(json_decode($file)); $mimetypemapping = get_object_vars(json_decode($dist));
//Check if need to load custom mappings
if (file_exists(OC::$SERVERROOT . '/config/mimetypemapping.json')) {
$custom = file_get_contents(OC::$SERVERROOT . '/config/mimetypemapping.json');
$custom_mapping = get_object_vars(json_decode($custom));
$mimetypemapping = array_merge($mimetypemapping, $custom_mapping);
}
self::$mimetypeDetector = new \OC\Files\Type\Detection(); self::$mimetypeDetector = new \OC\Files\Type\Detection();
self::$mimetypeDetector->registerTypeArray($mimetypemapping); self::$mimetypeDetector->registerTypeArray($mimetypemapping);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment