File.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. // use OCP namespace for all classes that are considered public.
  8. // This means that they should be used by apps instead of the internal Nextcloud classes
  9. namespace OCP\Files;
  10. use OCP\Lock\LockedException;
  11. /**
  12. * Interface File
  13. *
  14. * @since 6.0.0
  15. */
  16. interface File extends Node {
  17. /**
  18. * Get the content of the file as string
  19. *
  20. * @return string
  21. * @throws NotPermittedException
  22. * @throws GenericFileException
  23. * @throws LockedException
  24. * @since 6.0.0
  25. */
  26. public function getContent();
  27. /**
  28. * Write to the file from string data
  29. *
  30. * @param string|resource $data
  31. * @throws NotPermittedException
  32. * @throws GenericFileException
  33. * @throws LockedException
  34. * @since 6.0.0
  35. */
  36. public function putContent($data);
  37. /**
  38. * Get the mimetype of the file
  39. *
  40. * @return string
  41. * @since 6.0.0
  42. */
  43. public function getMimeType();
  44. /**
  45. * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen
  46. *
  47. * @param string $mode
  48. * @return resource|false
  49. * @throws NotPermittedException
  50. * @throws LockedException
  51. * @since 6.0.0
  52. */
  53. public function fopen($mode);
  54. /**
  55. * Compute the hash of the file
  56. * Type of hash is set with $type and can be anything supported by php's hash_file
  57. *
  58. * @param string $type
  59. * @param bool $raw
  60. * @return string
  61. * @since 6.0.0
  62. */
  63. public function hash($type, $raw = false);
  64. /**
  65. * Get the stored checksum for this file
  66. *
  67. * @return string
  68. * @since 9.0.0
  69. * @throws InvalidPathException
  70. * @throws NotFoundException
  71. */
  72. public function getChecksum();
  73. /**
  74. * Get the extension of this file
  75. *
  76. * @return string
  77. * @since 15.0.0
  78. */
  79. public function getExtension(): string;
  80. }