diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-04-09 15:19:57 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-07-27 14:58:45 +0200 |
commit | 6db6689740a5d11dd53b2502d1eea6e9157479df (patch) | |
tree | 276787c9cca5355c5faf50de3b76294b97cca559 /lib/public | |
parent | 4edfadac96fcf267c97371e67e5feccec94b337e (diff) | |
download | nextcloud-server-6db6689740a5d11dd53b2502d1eea6e9157479df.tar.gz nextcloud-server-6db6689740a5d11dd53b2502d1eea6e9157479df.zip |
Added mimetype detector
* Copied unit tests from old functions
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(); } |