Zendesk\API\Traits\Resource\MultipartUpload::upload PHP Метод

upload() публичный Метод

Uploads an file with the given upload name.
public upload ( array $params, string $routeKey = __FUNCTION__ ) : null | stdClass
$params array
$routeKey string
Результат null | stdClass
    public function upload(array $params, $routeKey = __FUNCTION__)
    {
        if (!array_key_exists('file', $params)) {
            throw new MissingParametersException(__METHOD__, ['file']);
        }
        if (!file_exists($params['file'])) {
            throw new CustomException('File ' . $params['file'] . ' could not be found in ' . __METHOD__);
        }
        try {
            $route = $this->getRoute($routeKey, $params);
        } catch (RouteException $e) {
            if (!isset($this->resourceName)) {
                $this->resourceName = $this->getResourceNameFromClass();
            }
            $this->setRoute(__FUNCTION__, $this->resourceName . '/uploads.json');
            $route = $this->resourceName . '/uploads.json';
        }
        $response = Http::send($this->client, $route, ['method' => $this->getUploadRequestMethod(), 'multipart' => [['name' => $this->getUploadName(), 'contents' => new LazyOpenStream($params['file'], 'r'), 'filename' => $params['file']]]]);
        return $response;
    }