Ejemplo n.º 1
0
 /**
  * @param string $filename
  * @param string $mimeType
  * @return Blob
  * @throws NuxeoClientException
  */
 public static function fromFile($filename, $mimeType)
 {
     $fileInfo = new \SplFileInfo($filename);
     if ($fileInfo->isReadable()) {
         return new Blob($fileInfo->getFilename(), $fileInfo, $mimeType);
     } else {
         throw NuxeoClientException::fromPrevious(new NoSuchFileException($filename));
     }
 }
  /**
   * @param string $url
   * @param string $body
   * @param array $files
   * @return Response
   * @throws NuxeoClientException
   */
  public function post($url, $body = null, $files = array()) {
    /** @var EntityEnclosingRequest $request */
    $request = $this->getHttpClient()->createRequest(Request::POST, $url, null, $body);

    foreach($files as $file) {
      $request->addRelatedFile($file);
    }

    $this->interceptors($request);
    try {
      return $request->send();
    } catch(GuzzleException $ex) {
      throw NuxeoClientException::fromPrevious($ex);
    }
  }