72 if (!$this->repo_helper->checkAccess(
'write', $this->obj->getRefId())) {
73 throw new Forbidden(
"Permission denied. No write access for this file");
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);
Stream factory which enables the user to create streams without the knowledge of the concrete class...
extractSuffixFromFilename(string $filename)
static getPhpUploadSizeLimitInBytes()
ensureSuffix(string $title, ?string $suffix=null)