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());
70 public function put(
$data, ?
string $name = null): ?string
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 $version = $this->obj->getVersion(
true);
112 if ($this->versioning_enabled ||
$version === 0) {
114 $uri = $stream->getMetadata(
'uri');
115 if ($uri ===
'php://temp') {
116 $version = $this->obj->appendStream($stream, $name);
117 } elseif (($stream_content = (
string) $stream) !==
'') {
118 $version = $this->obj->appendStream(
119 Streams::ofString($stream_content),
124 $version = $this->obj->replaceWithStream($stream, $name);
140 public function get()
142 if (!$this->repo_helper->checkAccess(
"read", $this->obj->getRefId())) {
143 throw new Forbidden(
"Permission denied. No read access for this file");
146 if (($r_id = $this->obj->getResourceId()) &&
147 ($identification = $this->resource_manager->find($r_id))) {
148 return $this->resource_consumer->stream($identification)->getStream()->detach();
155 $title = $this->obj->getTitle();
156 $suffix = empty($this->obj->getFileExtension())
158 : $this->obj->getFileExtension();
165 return $return_title;
170 return $this->obj->getFileType();
180 $this->obj->getCreateDate()
191 return $this->obj->getFileSize();
199 $this->needs_size_check =
false;
204 if (!$this->repo_helper->checkAccess(
"write", $this->obj->getRefId())) {
205 throw new Forbidden(
'Permission denied');
208 if ($this->isDAVableObjTitle($name) &&
209 $name === $this->obj->checkFileExtension($this->getName(), $name)) {
211 $this->obj->update();
217 public function delete():
void 219 $this->repo_helper->deleteObject($this->obj->getRefId());
224 return $this->retrieveLastModifiedAsIntFromObjectLastUpdateString($this->obj->getLastUpdateDate());
const OBJECT_TITLE_NOT_DAVABLE
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...