3 declare(strict_types=1);
55 bool $versioning_enabled
59 $this->resource_manager = $resource_storage->
manage();
60 $this->resource_consumer = $resource_storage->
consume();
71 if (!$this->repo_helper->checkAccess(
'write', $this->obj->getRefId())) {
72 throw new Forbidden(
"Permission denied. No write access for this file");
77 if ($this->request->hasHeader(
"Content-Length")) {
78 $size = (
int) $this->request->getHeader(
"Content-Length")[0];
80 if ($size === 0 && $this->request->hasHeader(
'X-Expected-Entity-Length')) {
81 $size = (
int) $this->request->getHeader(
'X-Expected-Entity-Length')[0];
85 throw new Forbidden(
'File is too big');
88 if ($this->needs_size_check && $this->
getSize() === 0) {
89 $parent_ref_id = $this->repo_helper->getParentOfRefId($this->obj->getRefId());
90 $obj_id = $this->obj->getId();
91 $this->repo_helper->deleteObject($this->obj->getRefId());
93 $file_obj->setTitle($this->
getName());
94 $file_obj->setFileName($this->
getName());
96 $file_dav = $this->dav_factory->createDAVObject($file_obj, $parent_ref_id);
97 $file_dav->noSizeCheckNeeded();
98 $this->repo_helper->updateLocksAfterResettingObject($obj_id, $file_obj->getId());
99 return $file_dav->put(
$data);
102 $stream = Streams::ofResource(
$data);
104 if ($this->versioning_enabled ===
true ||
105 $this->obj->getVersion() === 0 && $this->obj->getMaxVersion() === 0) {
106 $this->obj->appendStream($stream, $this->obj->getTitle());
108 $this->obj->replaceWithStream($stream, $this->obj->getTitle());
119 public function get()
121 if (!$this->repo_helper->checkAccess(
"read", $this->obj->getRefId())) {
122 throw new Forbidden(
"Permission denied. No read access for this file");
125 if (($r_id = $this->obj->getResourceId()) &&
126 ($identification = $this->resource_manager->find($r_id))) {
127 return $this->resource_consumer->stream($identification)->getStream()->getContents();
130 throw new NotFound(
"File not found");
140 return $this->obj->getFileType();
149 $this->obj->getCreateDate()
159 return $this->obj->getFileSize();
167 $this->needs_size_check =
false;
172 if (!$this->repo_helper->checkAccess(
"write", $this->obj->getRefId())) {
173 throw new Forbidden(
'Permission denied');
176 if ($this->isDAVableObjTitle(
$name) &&
177 $name === $this->obj->checkFileExtension($this->getName(),
$name)) {
178 $this->obj->setTitle(
$name);
179 $this->obj->update();
185 public function delete():
void 187 $this->repo_helper->deleteObject($this->obj->getRefId());
192 return $this->retrieveLastModifiedAsIntFromObjectLastUpdateString($this->obj->getLastUpdateDate());
const OBJECT_TITLE_NOT_DAVABLE
RequestInterface $request
static getValidFilename(string $a_filename)
__construct(ilObjFile $obj, ilWebDAVRepositoryHelper $repo_helper, Services $resource_storage, RequestInterface $request, ilWebDAVObjFactory $dav_factory, bool $versioning_enabled)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getUploadSizeLimitBytes()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilWebDAVRepositoryHelper $repo_helper
Manager $resource_manager
Consumers $resource_consumer
ilWebDAVObjFactory $dav_factory
trait ilObjFileNews
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...