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.

112 lines
2.6 KiB

3 years ago
  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. * @since 6.0.0
  37. */
  38. interface File extends Node {
  39. /**
  40. * Get the content of the file as string
  41. *
  42. * @return string
  43. * @throws NotPermittedException
  44. * @throws LockedException
  45. * @since 6.0.0
  46. */
  47. public function getContent();
  48. /**
  49. * Write to the file from string data
  50. *
  51. * @param string|resource $data
  52. * @throws NotPermittedException
  53. * @throws GenericFileException
  54. * @throws LockedException
  55. * @since 6.0.0
  56. */
  57. public function putContent($data);
  58. /**
  59. * Get the mimetype of the file
  60. *
  61. * @return string
  62. * @since 6.0.0
  63. */
  64. public function getMimeType();
  65. /**
  66. * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen
  67. *
  68. * @param string $mode
  69. * @return resource
  70. * @throws NotPermittedException
  71. * @throws LockedException
  72. * @since 6.0.0
  73. */
  74. public function fopen($mode);
  75. /**
  76. * Compute the hash of the file
  77. * Type of hash is set with $type and can be anything supported by php's hash_file
  78. *
  79. * @param string $type
  80. * @param bool $raw
  81. * @return string
  82. * @since 6.0.0
  83. */
  84. public function hash($type, $raw = false);
  85. /**
  86. * Get the stored checksum for this file
  87. *
  88. * @return string
  89. * @since 9.0.0
  90. * @throws InvalidPathException
  91. * @throws NotFoundException
  92. */
  93. public function getChecksum();
  94. /**
  95. * Get the extension of this file
  96. *
  97. * @return string
  98. * @since 15.0.0
  99. */
  100. public function getExtension(): string;
  101. }