• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/document/cloudimport/importmanager.php
  • Класс: BitrixDiskDocumentCloudImportImportManager
  • Вызов: ImportManager::uploadEmptyFileFromGoogle
protected function uploadEmptyFileFromGoogle(Entry $entry, DocumentFileData $fileData)
{
	$tmpFile = $fileData->getSrc();

	$downloadedContentSize = $entry->getDownloadedContentSize();
	$startRange = $downloadedContentSize;

	//fix for Google. It doesn't get in metadata real size of empty file.
	if(!$this->documentHandler->downloadFile($fileData))
	{
		$this->errorCollection->add($this->documentHandler->getErrors());
		return false;
	}
	$realFile = new IOFile($tmpFile);
	$contentSize = $realFile->getSize();
	$entry->setContentSize($contentSize);
	$chunkSize = $contentSize - $downloadedContentSize;

	$uploadFileManager = $this->uploadFileManager;
	$uploadFileManager
		->setFileSize($contentSize)
		->setEntry($entry)
		->setContentRange(array($startRange, $startRange + $chunkSize - 1))
	;
	$tmpFileArray = CFile::makeFileArray($tmpFile);
	if(!$uploadFileManager->upload($fileData->getId(), $tmpFileArray))
	{
		$this->errorCollection->add($uploadFileManager->getErrors());
		return false;
	}
	$entry->linkTmpFile(TmpFile::load(array('=TOKEN' => $uploadFileManager->getToken())));

	return $entry->increaseDownloadedContentSize($chunkSize);
}