($name, $data = null)
| 195 | } |
| 196 | |
| 197 | public function createFile($name, $data = null): INode |
| 198 | { |
| 199 | $folderKey = $this->folderKeyForPath($this->path); |
| 200 | $name = basename(trim((string)$name)); |
| 201 | |
| 202 | if (FolderCrypto::isEncryptedOrAncestor($folderKey)) { |
| 203 | throw new Forbidden('WebDAV is disabled inside encrypted folders'); |
| 204 | } |
| 205 | |
| 206 | if (!$this->isAdmin && !ACL::canWrite($this->user, $this->perms, $folderKey)) { |
| 207 | throw new Forbidden('No write access to this folder'); |
| 208 | } |
| 209 | if (!empty($this->perms['disableUpload']) && !$this->isAdmin) { |
| 210 | throw new Forbidden('Uploads are disabled for your account'); |
| 211 | } |
| 212 | if (!FileRiseFile::isAllowedWebDavFileName($name)) { |
| 213 | throw new Forbidden('Invalid file name.'); |
| 214 | } |
| 215 | |
| 216 | // Write directly to FS, then ensure metadata via FileRiseFile::put() |
| 217 | $full = $this->path . DIRECTORY_SEPARATOR . $name; |
| 218 | |
| 219 | // Let FileRiseFile handle metadata & overwrite semantics |
| 220 | $fileNode = new FileRiseFile($full, $this->user, $this->isAdmin, $this->perms); |
| 221 | $fileNode->put($data); |
| 222 | |
| 223 | return $fileNode; |
| 224 | } |
| 225 | |
| 226 | public function createDirectory($name): INode |
| 227 | { |
nothing calls this directly
no test coverage detected