You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IMimeTypeDetector.php 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Roeland Jago Douma <roeland@famdouma.nl>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. // use OCP namespace for all classes that are considered public.
  24. // This means that they should be used by apps instead of the internal ownCloud classes
  25. namespace OCP\Files;
  26. /**
  27. * Interface IMimeTypeDetector
  28. * @since 8.2.0
  29. *
  30. * Interface to handle mimetypes (detection and icon retrieval)
  31. **/
  32. interface IMimeTypeDetector {
  33. /**
  34. * detect mimetype only based on filename, content of file is not used
  35. * @param string $path
  36. * @return string
  37. * @since 8.2.0
  38. */
  39. public function detectPath($path);
  40. /**
  41. * detect mimetype only based on the content of file
  42. * @param string $path
  43. * @return string
  44. * @since 18.0.0
  45. */
  46. public function detectContent(string $path): string;
  47. /**
  48. * detect mimetype based on both filename and content
  49. *
  50. * @param string $path
  51. * @return string
  52. * @since 8.2.0
  53. */
  54. public function detect($path);
  55. /**
  56. * Get a secure mimetype that won't expose potential XSS.
  57. *
  58. * @param string $mimeType
  59. * @return string
  60. * @since 8.2.0
  61. */
  62. public function getSecureMimeType($mimeType);
  63. /**
  64. * detect mimetype based on the content of a string
  65. *
  66. * @param string $data
  67. * @return string
  68. * @since 8.2.0
  69. */
  70. public function detectString($data);
  71. /**
  72. * Get path to the icon of a file type
  73. * @param string $mimeType the MIME type
  74. * @return string the url
  75. * @since 8.2.0
  76. */
  77. public function mimeTypeIcon($mimeType);
  78. /**
  79. * @return array<string,string>
  80. * @since 28.0.0
  81. */
  82. public function getAllAliases(): array;
  83. }