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