public function importUrlAction()
{
$success = true;
$data = Tool::getHttpData($this->getParam("url"));
$filename = basename($this->getParam("url"));
$parentId = $this->getParam("id");
$parentAsset = Asset::getById(intval($parentId));
$filename = Element\Service::getValidKey($filename, "asset");
$filename = $this->getSafeFilename($parentAsset->getRealFullPath(), $filename);
if (empty($filename)) {
throw new \Exception("The filename of the asset is empty");
}
// check for duplicate filename
$filename = $this->getSafeFilename($parentAsset->getRealFullPath(), $filename);
if ($parentAsset->isAllowed("create")) {
$asset = Asset::create($parentId, ["filename" => $filename, "data" => $data, "userOwner" => $this->user->getId(), "userModification" => $this->user->getId()]);
$success = true;
} else {
Logger::debug("prevented creating asset because of missing permissions");
}
$this->_helper->json(["success" => $success]);
}