- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/document/upload/onedriveresumableupload.php
- Класс: BitrixDiskDocumentUploadOneDriveResumableUpload
- Вызов: OneDriveResumableUpload::getLocationForResumableUpload
protected function getLocationForResumableUpload()
{
if(!$this->checkRequiredInputParams($this->fileData->toArray(), array(
'name', 'size',
)))
{
return null;
}
$http = new HttpClient(array(
'redirect' => false,
'socketTimeout' => 10,
'streamTimeout' => 30,
'version' => HttpClient::HTTP_1_1,
));
$this->setBearer($http);
$http->setHeader('Content-Type', 'application/json; charset=UTF-8');
$postFields = Json::encode($this->getPostFieldsForUpload($this->fileData));
if($http->post($this->uploadPath . static::SUFFIX_TO_CREATE_UPLOAD_SESSION, $postFields) === false)
{
$errorString = implode('; ', array_keys($http->getError()));
$this->errorCollection[] = new Error(
$errorString, self::ERROR_HTTP_GET_LOCATION_FOR_UPLOAD
);
return null;
}
if(!$this->documentHandler->checkHttpResponse($http))
{
return null;
}
$responseData = Json::decode($http->getResult());
if($responseData === null)
{
$this->errorCollection->add(array(
new Error('Could not decode response as json', self::ERROR_BAD_JSON)
));
return null;
}
return $responseData['uploadUrl'];
}