- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/uf/controller.php
- Класс: BitrixDiskUfController
- Вызов: Controller::processActionUploadChunk
protected function processActionUploadChunk()
{
$this->checkRequiredPostParams(array('cloudImportId',));
if($this->errorCollection->hasErrors())
{
$this->sendJsonErrorResponse();
}
$cloudImport = CloudImportEntry::load(array(
'ID' => $this->request->getPost('cloudImportId'),
'USER_ID' => $this->getUser()->getId(),
));
if(!$cloudImport)
{
$this->errorCollection->addOne(new Error('Could not find cloud import', self::ERROR_COULD_NOT_FIND_CLOUD_IMPORT));
$this->sendJsonErrorResponse();
}
$documentHandlersManager = Driver::getInstance()->getDocumentHandlersManager();
$documentHandler = $documentHandlersManager->getHandlerByCode($cloudImport->getService());
if(!$documentHandler)
{
$this->errorCollection->add($documentHandlersManager->getErrors());
$this->sendJsonErrorResponse();
}
if(!$documentHandler->checkAccessibleTokenService())
{
$this->errorCollection->add(array(new Error(Loc::getMessage('DISK_UF_CONTROLLER_ERROR_COULD_NOT_WORK_WITH_TOKEN_SERVICE_B24', array('#NAME#' => $documentHandler::getName())), self::ERROR_COULD_NOT_WORK_WITH_TOKEN_SERVICE)));
$this->errorCollection->add($documentHandler->getErrors());
$this->sendJsonErrorResponse();
}
if(!$documentHandler->queryAccessToken()->hasAccessToken() || $documentHandler->isRequiredAuthorization())
{
$this->sendNeedAuth($documentHandler->getUrlForAuthorizeInTokenService('opener'));
}
$importManager = new CloudImportImportManager($documentHandler);
if(!$importManager->uploadChunk($cloudImport))
{
$this->errorCollection->add($importManager->getErrors());
$this->sendJsonErrorResponse();
}
$this->sendJsonSuccessResponse(array(
'step' => $cloudImport->isDownloaded()? 'finish' : 'download',
'contentSize' => (int)$cloudImport->getContentSize(),
'downloadedContentSize' => (int)$cloudImport->getDownloadedContentSize(),
));
}