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

Replace / overwrite files via WebDAV #4669

Open
BlackbitNeueMedien opened this issue Jul 11, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@BlackbitNeueMedien
Copy link
Contributor

commented Jul 11, 2019

Currently it is not possible to update an asset via WebDAV, is it? If you upload a file with the same file name you get the error "Duplicate full path [ ] - cannot save asset". This is caused by

public function createFile($name, $data = null)
{
$tmpFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . '/asset-dav-tmp-file-' . uniqid();
file_put_contents($tmpFile, $data);
$user = AdminTool::getCurrentUser();
if ($this->asset->isAllowed('create')) {
$asset = Asset::create($this->asset->getId(), [
'filename' => Element\Service::getValidKey($name, 'asset'),
'sourcePath' => $tmpFile,
'userModification' => $user->getId(),
'userOwner' => $user->getId()
]);
unlink($tmpFile);
} else {
throw new DAV\Exception\Forbidden();
}
}

Or is there another way to update an existing asset?
(Removing and reuploading of course is no option as references to the asset get lost)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.