1 | <?php |
||
37 | class QuotaPlugin extends \Sabre\DAV\ServerPlugin { |
||
38 | |||
39 | /** |
||
40 | * @var \OC\Files\View |
||
41 | */ |
||
42 | private $view; |
||
43 | |||
44 | /** |
||
45 | * Reference to main server object |
||
46 | * |
||
47 | * @var \Sabre\DAV\Server |
||
48 | */ |
||
49 | private $server; |
||
50 | |||
51 | /** |
||
52 | * @param \OC\Files\View $view |
||
53 | */ |
||
54 | 30 | public function __construct($view) { |
|
57 | |||
58 | /** |
||
59 | * This initializes the plugin. |
||
60 | * |
||
61 | * This function is called by \Sabre\DAV\Server, after |
||
62 | * addPlugin is called. |
||
63 | * |
||
64 | * This method should set up the requires event subscriptions. |
||
65 | * |
||
66 | * @param \Sabre\DAV\Server $server |
||
67 | * @return void |
||
68 | */ |
||
69 | 30 | public function initialize(\Sabre\DAV\Server $server) { |
|
76 | |||
77 | /** |
||
78 | * This method is called before any HTTP method and validates there is enough free space to store the file |
||
79 | * |
||
80 | * @param string $uri |
||
81 | * @param null $data |
||
82 | * @throws \Sabre\DAV\Exception\InsufficientStorage |
||
83 | * @return bool |
||
84 | */ |
||
85 | 22 | public function checkQuota($uri, $data = null) { |
|
113 | |||
114 | 27 | public function getLength() { |
|
115 | 27 | $req = $this->server->httpRequest; |
|
116 | 27 | $length = $req->getHeader('X-Expected-Entity-Length'); |
|
117 | 27 | if (!is_numeric($length)) { |
|
118 | 22 | $length = $req->getHeader('Content-Length'); |
|
119 | 22 | $length = is_numeric($length) ? $length : null; |
|
120 | } |
||
121 | 27 | ||
122 | 27 | $ocLength = $req->getHeader('OC-Total-Length'); |
|
123 | 5 | if (is_numeric($length) && is_numeric($ocLength)) { |
|
124 | return max($length, $ocLength); |
||
125 | } |
||
126 | 22 | ||
127 | return $length; |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * @param string $parentUri |
||
132 | * @return mixed |
||
133 | 9 | */ |
|
134 | public function getFreeSpace($parentUri) { |
||
142 | } |
||
143 |