/** * @param string $path * @param WriteMode $writeMode * @param callable $curlConfigClosure * @return array */ private function _uploadFile($path, $writeMode, $curlConfigClosure) { Path::checkArg("path", $path); WriteMode::checkArg("writeMode", $writeMode); Checker::argCallable("curlConfigClosure", $curlConfigClosure); $url = $this->buildUrlForGetOrPut($this->contentHost, $this->appendFilePath("1/files_put", $path), $writeMode->getExtraParams()); $curl = $this->mkCurl($url); $curlConfigClosure($curl); $curl->set(CURLOPT_RETURNTRANSFER, true); $response = $curl->exec(); if ($response->statusCode !== 200) { throw RequestUtil::unexpectedStatus($response); } return RequestUtil::parseResponseJson($response->body); }