2use Sabre\DAV\Exception;
3use Sabre\DAV\Exception\Forbidden;
46 $this->resource_manager =
$DIC->resourceStorage()->manage();
47 $this->resource_consumer =
$DIC->resourceStorage()->consume();
48 $this->versioning_enabled = (bool) $settings->get(
'webdav_versioning_enabled',
true);
75 if ($this->repo_helper->checkAccess(
'write', $this->getRefId())) {
76 if ($this->versioning_enabled ===
true ||
77 $this->obj->getVersion() ===
'1' && $this->getSize() === 0) {
84 throw new Exception\Forbidden(
"Permission denied. No write access for this file");
97 if ($this->repo_helper->checkAccess(
"read", $this->obj->getRefId())) {
106 if (($r_id = $this->obj->getResourceId()) &&
107 ($identification = $this->resource_manager->find($r_id))) {
108 return $this->resource_consumer->stream($identification)->getStream()->getContents();
115 return fopen($file,
'r');
118 throw new Exception\NotFound(
"File not found");
121 throw new Exception\Forbidden(
"Permission denied. No read access for this file");
143 return $this->obj->getFileType();
174 $this->obj->getCreateDate()
188 return $this->obj->getFileSize();
197 if ($this->dav_helper->isValidFileNameWithValidFileExtension($a_name)) {
198 parent::setName($a_name);
200 throw new Exception\Forbidden(
"Invalid file extension");
221 if ($a_file_action !=
'create' && file_exists($this->
getPathToFile())) {
224 $DIC->fileSystem()->storage(),
231 $size = (int) $this->request->getHeader(
'Content-Length')[0];
233 if (
$size === 0 && $this->request->hasHeader(
'X-Expected-Entity-Length')) {
234 $size = $this->request->getHeader(
'X-Expected-Entity-Length')[0];
238 throw new Exception\Forbidden(
'File is too big');
241 $stream = Streams::ofResource($a_data);
243 if ($a_file_action ===
'replace') {
244 $this->obj->replaceWithStream($stream, $this->obj->getTitle());
246 $this->obj->appendStream($stream, $this->obj->getTitle());
253 if ($this->obj->update()) {
264 return $this->obj->getDirectory($this->obj->getVersion());
289 if ($vrs[0] ==
false) {
290 ilLoggerFactory::getLogger(
'WebDAV')->error(get_class($this) .
' ' . $this->obj->getTitle() .
" -> virus found on '$file_dest_path'!");
291 throw new Exception\Forbidden(
'Virus found!');
306 ilHistory::_createEntry($this->obj->getId(), $a_action, $this->obj->getTitle() .
"," . $this->obj->getVersion() .
"," . $this->obj->getMaxVersion());
310 $this->obj->notifyUpdate($this->obj->getId());
318 if ($this->obj->getVersion() > 1) {
319 $version_dir = $this->obj->getDirectory($this->obj->getVersion());
322 $this->obj->deleteVersions();
323 $this->obj->delete();
An exception for terminatinating execution or to throw for unit testing.
Class Streams Stream factory which enables the user to create streams without the knowledge of the co...
Class ilFileObjectToStorageDirectory.
static getValidFilename($a_filename)
Get valid filename.
static _createEntry( $a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
static getLogger($a_component_id)
Get component logger.
getSize()
Returns the size of the node, in bytes.
getName()
Returns title of file object.
deleteObjOrVersion()
Delete an object if there is no other version in it otherwise delete version.
put($data)
Replaces the contents of the file.
__construct(ilObjFile $a_obj, ilWebDAVRepositoryHelper $repo_helper, ilWebDAVObjDAVHelper $dav_helper)
ilObjFileDAV represents the WebDAV-Interface to an ILIAS-Object
getContentType()
Returns the mime-type for a file.
handleFileUpload($a_data, $a_file_action)
Handle uploaded file.
checkForVirus(string $file_dest_path)
createHistoryAndNotificationForObjUpdate($a_action)
Create history entry and a news notification for file object update.
getETag()
Returns the ETag for a file.
getPathToFile()
This method only exists for legacy reasons.
static createPreview($a_obj, $a_force=false)
Creates the preview for the object with the specified id.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getUploadSizeLimitBytes()
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
Class ilWebDAVObjDAVHelper.
Class ilWebDAVRepositoryHelper.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc