public static function getMapReferenceAttributes() { return array('OBJECT' => BaseObject::className(), 'VERSION' => Version::className(), 'TMP_FILE' => TmpFile::className(), 'USER' => array('class' => User::className(), 'select' => User::getFieldsForSelect())); }
/** * Fix for Google. It does not get in metadata real size of empty file. * @param Entry $entry * @param Document\FileData $fileData * @return bool * @throws IO\FileNotFoundException * @throws \Bitrix\Main\SystemException */ protected function uploadEmptyFileFromGoogle(Entry $entry, Document\FileData $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 IO\File($tmpFile); $contentSize = $realFile->getSize(); $entry->setContentSize($contentSize); $chunkSize = $contentSize - $downloadedContentSize; $uploadFileManager = new Bitrix24Disk\UploadFileManager(); $uploadFileManager->setTmpFileClass(TmpFile::className())->setUser($this->documentHandler->getUserId())->setFileSize($contentSize)->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); }