Пример #1
0
 protected function processActionRollbackUpload()
 {
     $this->enableIgnoreQuotaError();
     $this->checkRequiredPostParams(array('token'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $tmpFileManager = new Bitrix24Disk\UploadFileManager();
     $tmpFileManager->setToken($this->request->getPost('token'))->setUser($this->getUser());
     if (!$tmpFileManager->rollbackByToken()) {
         $this->errorCollection->add($tmpFileManager->getErrors());
         $this->sendJsonErrorResponse();
     }
     $this->sendJsonSuccessResponse();
 }
Пример #2
0
 /**
  * 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);
 }