apiClient = new UploadApiClient($configuration); } /** * Gets Upload API end point. * * @param string $action The action to perform. * * @param array $options Additional options. * * @return string * * @internal */ protected static function getUploadApiEndPoint($action, $options = []) { return ArrayUtils::implodeUrl([ArrayUtils::get($options, 'resource_type', AssetType::IMAGE), $action]); } /** * Gets upload URL for the specified asset type and endpoint. * * @param string $assetType The asset type. * @param string $endPoint The endpoint name. * @param array $params Additional query parameters. * * @return string */ public function getUploadUrl($assetType = AssetType::AUTO, $endPoint = UploadEndPoint::UPLOAD, $params = []) { $baseUrl = $this->apiClient->getBaseUri(); $path = self::getUploadApiEndPoint($endPoint, ['resource_type' => $assetType]); return ArrayUtils::implodeFiltered('?', ["{$baseUrl}{$path}", Utils::buildHttpQuery($params)]); } /** * Gets cloud config of the current instance. * * @return CloudConfig * * @internal */ public function getCloud() { return $this->apiClient->getCloud(); } /** * Internal method for performing all Upload API calls. * * @param string $endPoint The relative endpoint. * @param array $params Parameters to pass to the endpoint. * @param array $options Additional options. * * @return PromiseInterface * * @internal */ protected function callUploadApiAsync($endPoint = UploadEndPoint::UPLOAD, $params = [], $options = []) { return $this->apiClient->postAndSignFormAsync( self::getUploadApiEndPoint($endPoint, $options), ApiUtils::finalizeUploadApiParams($params) ); } /** * Internal method for performing all Upload API calls as a json. * * @param string $endPoint The relative endpoint. * @param array $params Parameters to pass to the endpoint. * @param array $options Additional options. * * @return PromiseInterface * * @internal */ protected function callUploadApiJsonAsync($endPoint = UploadEndPoint::UPLOAD, $params = [], $options = []) { return $this->apiClient->postAndSignJsonAsync( self::getUploadApiEndPoint($endPoint, $options), ApiUtils::finalizeUploadApiParams($params) ); } }