Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebDAV: Fix Uploading Files #8727

Open
wants to merge 2 commits into
base: release_8
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Services/WebDAV/classes/dav/class.ilDAVFile.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
Expand All @@ -18,6 +16,8 @@
*
*********************************************************************/

declare(strict_types=1);

use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use ILIAS\Filesystem\Stream\Streams;
Expand Down Expand Up @@ -103,9 +103,9 @@ public function put($data): ?string

if ($this->versioning_enabled === true ||
$this->obj->getVersion() === 0 && $this->obj->getMaxVersion() === 0) {
$this->obj->appendStream($stream, $this->obj->getTitle());
$this->obj->appendStream($stream, $this->obj->getFileName());
} else {
$this->obj->replaceWithStream($stream, $this->obj->getTitle());
$this->obj->replaceWithStream($stream, $this->obj->getFileName());
}

$stream->close();
Expand All @@ -132,7 +132,13 @@ public function get()

public function getName(): string
{
return ilFileUtils::getValidFilename($this->obj->getTitle());
$name = $this->obj->getTitle();
$name_array = explode('.', $name);
$filename_array = explode('.', $this->obj->getFileName());
if (end($name_array) !== end($filename_array)) {
$name .= '.' . end($filename_array);
}
return ilFileUtils::getValidFilename($name);
}

public function getContentType(): ?string
Expand Down
Loading