File.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Julius Härtl <jus@bitgrid.net>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. /**
  26. * Public interface of ownCloud for apps to use.
  27. * Files/File interface
  28. */
  29. // use OCP namespace for all classes that are considered public.
  30. // This means that they should be used by apps instead of the internal ownCloud classes
  31. namespace OCP\Files;
  32. use OCP\Lock\LockedException;
  33. /**
  34. * Interface File
  35. *
  36. * @package OCP\Files
  37. * @since 6.0.0
  38. */
  39. interface File extends Node {
  40. /**
  41. * Get the content of the file as string
  42. *
  43. * @return string
  44. * @throws NotPermittedException
  45. * @throws LockedException
  46. * @since 6.0.0
  47. */
  48. public function getContent();
  49. /**
  50. * Write to the file from string data
  51. *
  52. * @param string|resource $data
  53. * @throws NotPermittedException
  54. * @throws GenericFileException
  55. * @throws LockedException
  56. * @since 6.0.0
  57. */
  58. public function putContent($data);
  59. /**
  60. * Get the mimetype of the file
  61. *
  62. * @return string
  63. * @since 6.0.0
  64. */
  65. public function getMimeType();
  66. /**
  67. * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen
  68. *
  69. * @param string $mode
  70. * @return resource
  71. * @throws NotPermittedException
  72. * @throws LockedException
  73. * @since 6.0.0
  74. */
  75. public function fopen($mode);
  76. /**
  77. * Compute the hash of the file
  78. * Type of hash is set with $type and can be anything supported by php's hash_file
  79. *
  80. * @param string $type
  81. * @param bool $raw
  82. * @return string
  83. * @since 6.0.0
  84. */
  85. public function hash($type, $raw = false);
  86. /**
  87. * Get the stored checksum for this file
  88. *
  89. * @return string
  90. * @since 9.0.0
  91. * @throws InvalidPathException
  92. * @throws NotFoundException
  93. */
  94. public function getChecksum();
  95. /**
  96. * Get the extension of this file
  97. *
  98. * @return string
  99. * @since 15.0.0
  100. */
  101. public function getExtension(): string;
  102. }