• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/controller/file.php
  • Класс: BitrixDiskControllerFile
  • Вызов: File::copyToMeAction
public function copyToMeAction(DiskFile $file)
{
	$currentUserId = $this->getCurrentUser()->getId();
	$userStorage = Driver::getInstance()->getStorageByUserId($currentUserId);
	if (!$userStorage)
	{
		$this->addError(new Error('Could not find storage for current user'));

		return null;
	}
	$folder = $userStorage->getFolderForSavedFiles();
	if (!$folder)
	{
		$this->addError(new Error('Could not find folder for created files'));

		return null;
	}

	//so, now we don't copy links in the method copyTo. But here we have to copy content.
	//And after we set name to new object as it was on link.
	$newFile = $file->getRealObject()->copyTo($folder, $currentUserId, true);
	if ($file->getRealObject()->getName() != $file->getName())
	{
		$newFile->renameInternal($file->getName(), true);
	}

	if (!$newFile)
	{
		$this->addError(new Error('Could not copy file to storage for current user'));

		return null;
	}

	return $this->get($newFile);
}