19 declare(strict_types=1);
52 protected bool $versioning_enabled
54 $this->resource_manager = $resource_storage->
manage();
55 $this->resource_consumer = $resource_storage->
consume();
60 $this->repo_helper->locks()->purgeExpiredLocksFromDB();
61 $lock = $this->repo_helper->locks()->getLockObjectWithObjIdFromDB($this->obj->getId());
63 $this->repo_helper->locks()->removeLockWithTokenFromDB($lock->getToken());
72 if (!$this->repo_helper->checkAccess(
'write', $this->obj->getRefId())) {
73 throw new Forbidden(
"Permission denied. No write access for this file");
82 $stream = is_resource(
$data) ? Streams::ofResource(
$data) : Streams::ofString(
$data);
83 $stream_size = $stream->getSize();
85 if ($this->request->hasHeader(
"Content-Length")) {
86 $size = (
int) $this->request->getHeader(
"Content-Length")[0];
88 if ($size === 0 && $this->request->hasHeader(
'X-Expected-Entity-Length')) {
89 $size = (
int) $this->request->getHeader(
'X-Expected-Entity-Length')[0];
94 throw new Forbidden(
'File is too big');
97 if ($this->needs_size_check && $this->
getSize() === 0) {
98 $parent_ref_id = $this->repo_helper->getParentOfRefId($this->obj->getRefId());
99 $file_dav = $this->dav_factory->createDAVObject($this->obj, $parent_ref_id);
100 $file_dav->noSizeCheckNeeded();
102 return $file_dav->put(
$data);
105 $resource = $stream->detach();
106 if ($resource ===
null) {
109 $stream = Streams::ofResource($resource);
111 if ($this->versioning_enabled) {
112 $version = $this->obj->getVersion(
true);
113 if (($stream_content = (
string) $stream) !==
'') {
114 $version = $this->obj->appendStream(
115 Streams::ofString($stream_content),
120 $version = $this->obj->replaceWithStream($stream, $name);
136 public function get()
138 if (!$this->repo_helper->checkAccess(
"read", $this->obj->getRefId())) {
139 throw new Forbidden(
"Permission denied. No read access for this file");
142 if (($r_id = $this->obj->getResourceId()) &&
143 ($identification = $this->resource_manager->find($r_id))) {
144 return $this->resource_consumer->stream($identification)->getStream()->getContents();
151 $title = $this->obj->getTitle();
152 $suffix = empty($this->obj->getFileExtension())
154 : $this->obj->getFileExtension();
161 return $return_title;
166 return $this->obj->getFileType();
176 $this->obj->getCreateDate()
187 return $this->obj->getFileSize();
195 $this->needs_size_check =
false;
200 if (!$this->repo_helper->checkAccess(
"write", $this->obj->getRefId())) {
201 throw new Forbidden(
'Permission denied');
204 if ($this->isDAVableObjTitle($name) &&
205 $name === $this->obj->checkFileExtension($this->getName(), $name)) {
207 $this->obj->update();
213 public function delete():
void 215 $this->repo_helper->deleteObject($this->obj->getRefId());
220 return $this->retrieveLastModifiedAsIntFromObjectLastUpdateString($this->obj->getLastUpdateDate());
const OBJECT_TITLE_NOT_DAVABLE
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
extractSuffixFromFilename(string $filename)
__construct(protected ilObjFile $obj, protected ilWebDAVRepositoryHelper $repo_helper, Services $resource_storage, protected RequestInterface $request, protected ilWebDAVObjFactory $dav_factory, protected bool $versioning_enabled)
trait ilObjFileSecureString
Trait ilObjFileSecureString.
Manager $resource_manager
static getPhpUploadSizeLimitInBytes()
Consumers $resource_consumer
put($data, ?string $name=null)
ensureSuffix(string $title, ?string $suffix=null)
trait ilObjFileNews
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...