• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/vk/api/apihelper.php
  • Класс: BitrixSaleTradingPlatformVkApiApiHelper
  • Вызов: ApiHelper::uploadHttp
private function uploadHttp($uploadServer, $params)
{
	$http = new HttpClient();
	$boundary = md5(rand() . time());

	$file = $this->getFile($params["url"]);

	$data = '--' . $boundary . "rn";
	$data .= 'Content-Disposition: form-data; name="' . $params["param_name"] . '"; filename="' . $params["filename"] . '"' . "rn";
	$data .= 'Content-Type: application/octet-stream' . "rnrn";
	$data .= $file . "rn";
	$data .= '--' . $boundary . "--rn";
	
	$http->setHeader('Content-type', 'multipart/form-data; boundary=' . $boundary);
	$http->setHeader('Content-length', BitrixMainTextBinaryString::getLength($data));
	
	$this->logger->addLog("Upload photo HTTP params", [
		'SERVER' => $uploadServer,
		'PARAMS' => $params,
		'FILE_OK' => $file ? 'Y' : 'N',
	]);
	$result = $http->post($uploadServer, $data);
	
	$result = Json::decode($result);
	$this->logger->addLog("Upload photo HTTP response", $result);
	
//		check TIMER if set
	if (array_key_exists("timer", $params))
	{
		$timer = $params["timer"];
		if ($timer !== NULL && !$timer->check())
			throw new TimeIsOverException();
	}
	
	return $result;
}