Пример #1
0
 /**
  * @param $bucketId
  * @param string $filePath The path to the local file
  * @param string $fileName The name/path on B2
  * @param string $contentType
  * @param array $uploadUrlResponse
  * @return array
  */
 public function uploadFile($bucketId, $filePath, $fileName, $contentType, $uploadUrlResponse = [])
 {
     if (empty($uploadUrlResponse)) {
         $uploadUrlResponse = $this->getUploadUrl($bucketId);
     }
     $handle = fopen($filePath, 'r');
     $fileData = fread($handle, filesize($filePath));
     $fileDataSha1 = sha1_file($filePath);
     return $this->B2Client->uploadData($fileData, $fileDataSha1, $fileName, $contentType, $uploadUrlResponse['uploadUrl'], $uploadUrlResponse['authorizationToken']);
 }