MCPcopy Create free account
hub / github.com/error311/FileRise / createFile

Method createFile

src/FileRise/WebDAV/FileRiseDirectory.php:197–224  ·  view source on GitHub ↗
($name, $data = null)

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 5

folderKeyForPathMethod · 0.95
isEncryptedOrAncestorMethod · 0.80
canWriteMethod · 0.80
putMethod · 0.80

Tested by

no test coverage detected