1<?php
2
3namespace Sabre\DAV;
4
5/**
6 * File class
7 *
8 * This is a helper class, that should aid in getting file classes setup.
9 * Most of its methods are implemented, and throw permission denied exceptions
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 */
15abstract class File extends Node implements IFile {
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 string|resource $data
35     * @return string|null
36     */
37    function put($data) {
38
39        throw new Exception\Forbidden('Permission denied to change data');
40
41    }
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    function get() {
51
52        throw new Exception\Forbidden('Permission denied to read this file');
53
54    }
55
56    /**
57     * Returns the size of the file, in bytes.
58     *
59     * @return int
60     */
61    function getSize() {
62
63        return 0;
64
65    }
66
67    /**
68     * Returns the ETag for a file
69     *
70     * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.
71     * The ETag is an arbitrary string, but MUST be surrounded by double-quotes.
72     *
73     * Return null if the ETag can not effectively be determined
74     *
75     * @return string|null
76     */
77    function getETag() {
78
79        return null;
80
81    }
82
83    /**
84     * Returns the mime-type for a file
85     *
86     * If null is returned, we'll assume application/octet-stream
87     *
88     * @return string|null
89     */
90    function getContentType() {
91
92        return null;
93
94    }
95
96}
97