ISimpleFile.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCP\Files\SimpleFS;
  7. use OCP\Files\NotFoundException;
  8. use OCP\Files\NotPermittedException;
  9. /**
  10. * This interface allows to manage simple files.
  11. *
  12. * This interface must not be implemented in your application but
  13. * instead should be used as a service and injected in your code with
  14. * dependency injection.
  15. *
  16. * @since 11.0.0
  17. */
  18. interface ISimpleFile {
  19. /**
  20. * Get the name
  21. *
  22. * @since 11.0.0
  23. */
  24. public function getName(): string;
  25. /**
  26. * Get the size in bytes
  27. *
  28. * @since 11.0.0
  29. */
  30. public function getSize(): int|float;
  31. /**
  32. * Get the ETag
  33. *
  34. * @since 11.0.0
  35. */
  36. public function getETag(): string;
  37. /**
  38. * Get the last modification time
  39. *
  40. * @since 11.0.0
  41. */
  42. public function getMTime(): int;
  43. /**
  44. * Get the content
  45. *
  46. * @throws NotPermittedException
  47. * @throws NotFoundException
  48. * @since 11.0.0
  49. */
  50. public function getContent(): string;
  51. /**
  52. * Overwrite the file
  53. *
  54. * @param string|resource $data
  55. * @throws NotPermittedException
  56. * @throws NotFoundException
  57. * @since 11.0.0
  58. */
  59. public function putContent($data): void;
  60. /**
  61. * Delete the file
  62. *
  63. * @throws NotPermittedException
  64. * @since 11.0.0
  65. */
  66. public function delete(): void;
  67. /**
  68. * Get the MimeType
  69. *
  70. * @since 11.0.0
  71. */
  72. public function getMimeType(): string;
  73. /**
  74. * @since 24.0.0
  75. */
  76. public function getExtension(): string;
  77. /**
  78. * Open the file as stream for reading, resulting resource can be operated as stream like the result from php's own fopen
  79. *
  80. * @return resource|false
  81. * @throws \OCP\Files\NotPermittedException
  82. * @since 14.0.0
  83. */
  84. public function read();
  85. /**
  86. * Open the file as stream for writing, resulting resource can be operated as stream like the result from php's own fopen
  87. *
  88. * @return resource|bool
  89. * @throws \OCP\Files\NotPermittedException
  90. * @since 14.0.0
  91. */
  92. public function write();
  93. }