diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-07-28 13:35:26 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-28 13:35:26 +0200 |
commit | c34e63bb1f9752892d3c36b50e461b284f822a36 (patch) | |
tree | 760bce9904c5c05d6edfc32b3193fa95191ed800 /lib/public | |
parent | 73169b0edbc1086d2a287c26640e2a2428449971 (diff) | |
parent | d276aebf4099acd54dff7e727e25d28debf441b8 (diff) | |
download | nextcloud-server-c34e63bb1f9752892d3c36b50e461b284f822a36.tar.gz nextcloud-server-c34e63bb1f9752892d3c36b50e461b284f822a36.zip |
Merge pull request #15543 from rullzer/mimetypedetector
Mimetypedetector
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/files/imimetypedetector.php | 78 | ||||
-rw-r--r-- | lib/public/iservercontainer.php | 9 |
2 files changed, 87 insertions, 0 deletions
diff --git a/lib/public/files/imimetypedetector.php b/lib/public/files/imimetypedetector.php new file mode 100644 index 00000000000..79ed8a4fac9 --- /dev/null +++ b/lib/public/files/imimetypedetector.php @@ -0,0 +1,78 @@ +<?php +/** + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes +namespace OCP\Files; + + +/** + * Interface IMimeTypeDetector + * @package OCP\Files + * @since 8.2.0 + * + * Interface to handle mimetypes (detection and icon retrieval) + **/ +interface IMimeTypeDetector { + + /** + * detect mimetype only based on filename, content of file is not used + * @param string $path + * @return string + * @since 8.2.0 + **/ + public function detectPath($path); + + /** + * detect mimetype based on both filename and content + * + * @param string $path + * @return string + * @since 8.2.0 + */ + public function detect($path); + + /** + * Get a secure mimetype that won't expose potential XSS. + * + * @param string $mimeType + * @return string + * @since 8.2.0 + */ + public function getSecureMimeType($mimeType); + + /** + * detect mimetype based on the content of a string + * + * @param string $data + * @return string + * @since 8.2.0 + */ + public function detectString($data); + + /** + * Get path to the icon of a file type + * @param string $mimeType the MIME type + * @return string the url + * @since 8.2.0 + */ + public function mimeTypeIcon($mimeType); +} diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index 95ee853d84c..f3165db33da 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -9,6 +9,7 @@ * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> + * @author Roeland Jago Douma <roeland@famdouma.nl> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Thomas Tanghus <thomas@tanghus.net> * @@ -429,4 +430,12 @@ interface IServerContainer { * @since 8.2.0 */ public function getMountManager(); + + /** + * Get the MimeTypeDetector + * + * @return \OCP\Files\IMimeTypeDetector + * @since 8.2.0 + */ + public function getMimeTypeDetector(); } |