File.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. // use OCP namespace for all classes that are considered public.
  26. // This means that they should be used by apps instead of the internal ownCloud classes
  27. namespace OCP\Files;
  28. use OCP\Lock\LockedException;
  29. /**
  30. * Interface File
  31. *
  32. * @since 6.0.0
  33. */
  34. interface File extends Node {
  35. /**
  36. * Get the content of the file as string
  37. *
  38. * @return string
  39. * @throws NotPermittedException
  40. * @throws LockedException
  41. * @since 6.0.0
  42. */
  43. public function getContent();
  44. /**
  45. * Write to the file from string data
  46. *
  47. * @param string|resource $data
  48. * @throws NotPermittedException
  49. * @throws GenericFileException
  50. * @throws LockedException
  51. * @since 6.0.0
  52. */
  53. public function putContent($data);
  54. /**
  55. * Get the mimetype of the file
  56. *
  57. * @return string
  58. * @since 6.0.0
  59. */
  60. public function getMimeType();
  61. /**
  62. * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen
  63. *
  64. * @param string $mode
  65. * @return resource
  66. * @throws NotPermittedException
  67. * @throws LockedException
  68. * @since 6.0.0
  69. */
  70. public function fopen($mode);
  71. /**
  72. * Compute the hash of the file
  73. * Type of hash is set with $type and can be anything supported by php's hash_file
  74. *
  75. * @param string $type
  76. * @param bool $raw
  77. * @return string
  78. * @since 6.0.0
  79. */
  80. public function hash($type, $raw = false);
  81. /**
  82. * Get the stored checksum for this file
  83. *
  84. * @return string
  85. * @since 9.0.0
  86. * @throws InvalidPathException
  87. * @throws NotFoundException
  88. */
  89. public function getChecksum();
  90. /**
  91. * Get the extension of this file
  92. *
  93. * @return string
  94. * @since 15.0.0
  95. */
  96. public function getExtension(): string;
  97. }