IFile.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\DAV;
  4. /**
  5. * This interface represents a file in the directory tree.
  6. *
  7. * A file is a bit of a broad definition. In general it implies that on
  8. * this specific node a PUT or GET method may be performed, to either update,
  9. * or retrieve the contents of the file.
  10. *
  11. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  12. * @author Evert Pot (http://evertpot.com/)
  13. * @license http://sabre.io/license/ Modified BSD License
  14. */
  15. interface IFile extends INode
  16. {
  17. /**
  18. * Replaces the contents of the file.
  19. *
  20. * The data argument is a readable stream resource.
  21. *
  22. * After a successful put operation, you may choose to return an ETag. The
  23. * etag must always be surrounded by double-quotes. These quotes must
  24. * appear in the actual string you're returning.
  25. *
  26. * Clients may use the ETag from a PUT request to later on make sure that
  27. * when they update the file, the contents haven't changed in the mean
  28. * time.
  29. *
  30. * If you don't plan to store the file byte-by-byte, and you return a
  31. * different object on a subsequent GET you are strongly recommended to not
  32. * return an ETag, and just return null.
  33. *
  34. * @param resource|string $data
  35. *
  36. * @return string|null
  37. */
  38. public function put($data);
  39. /**
  40. * Returns the data.
  41. *
  42. * This method may either return a string or a readable stream resource
  43. *
  44. * @return mixed
  45. */
  46. public function get();
  47. /**
  48. * Returns the mime-type for a file.
  49. *
  50. * If null is returned, we'll assume application/octet-stream
  51. *
  52. * @return string|null
  53. */
  54. public function getContentType();
  55. /**
  56. * Returns the ETag for a file.
  57. *
  58. * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
  59. *
  60. * Return null if the ETag can not effectively be determined.
  61. *
  62. * The ETag must be surrounded by double-quotes, so something like this
  63. * would make a valid ETag:
  64. *
  65. * return '"someetag"';
  66. *
  67. * @return string|null
  68. */
  69. public function getETag();
  70. /**
  71. * Returns the size of the node, in bytes.
  72. *
  73. * @return int
  74. */
  75. public function getSize();
  76. }