- Модуль: clouds
- Путь к файлу: ~/bitrix/modules/clouds/classes/general/storage_service_google.php
- Класс: CCloudStorageService_GoogleStorage
- Вызов: CCloudStorageService_GoogleStorage::StartUpload
protected function StartUpload($arBucket, $filePath, $ContentType)
{
$filePath = '/'.trim($filePath, '/');
if($arBucket["PREFIX"])
{
if(mb_substr($filePath, 0, mb_strlen($arBucket["PREFIX"]) + 2) != "/".$arBucket["PREFIX"]."/")
$filePath = "/".$arBucket["PREFIX"].$filePath;
}
$filePathU = CCloudUtil::URLEncode($filePath, "UTF-8", true);
$response = $this->SendRequest(
$arBucket["SETTINGS"]["ACCESS_KEY"],
$arBucket["SETTINGS"]["SECRET_KEY"],
'POST',
$arBucket["BUCKET"],
$filePathU,
'',
'',
array(
"x-goog-acl"=>"public-read",
"x-goog-resumable"=>"start",
"Content-Type"=>$ContentType,
)
);
if(
$this->status == 201
&& is_array($this->headers)
&& isset($this->headers["Location"])
&& preg_match("/upload_id=(.*)$/", $this->headers["Location"], $match)
)
{
return array(
"filePath" => $filePath,
"filePos" => 0,
"upload_id" => $match[1],
);
}
if (defined("BX_CLOUDS_ERROR_DEBUG"))
{
AddMessage2Log($this);
}
return false;
}