File.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  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. /**
  33. * Interface File
  34. *
  35. * @package OCP\Files
  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 \OCP\Files\NotPermittedException
  44. * @since 6.0.0
  45. */
  46. public function getContent();
  47. /**
  48. * Write to the file from string data
  49. *
  50. * @param string $data
  51. * @throws \OCP\Files\NotPermittedException
  52. * @return void
  53. * @since 6.0.0
  54. */
  55. public function putContent($data);
  56. /**
  57. * Get the mimetype of the file
  58. *
  59. * @return string
  60. * @since 6.0.0
  61. */
  62. public function getMimeType();
  63. /**
  64. * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen
  65. *
  66. * @param string $mode
  67. * @return resource
  68. * @throws \OCP\Files\NotPermittedException
  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. }