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