1
0

File.php 2.5 KB

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