Ejemplo n.º 1
0
 public function testSetGetUploadClient()
 {
     $factory = $this->getClientFactory();
     $factory->expects($this->never())->method($this->anything());
     $clientStub = new GuzzleClient();
     $manager = new BoxClient\ClientManager('', $factory);
     $manager->setUploadClient($clientStub);
     $this->assertSame($clientStub, $manager->getUploadClient());
 }
Ejemplo n.º 2
0
 /**
  * @param $file
  * @param string $name
  * @param bool $nonSvg
  * @param array $thumbnails
  * @param null $fileName
  * @param array $fileHeaders
  * @return Response\Entity\Document
  */
 public function createDocumentFromFile($file, $name = '', $nonSvg = false, array $thumbnails = [], $fileName = null, $fileHeaders = [])
 {
     if ($file instanceof \SplFileInfo) {
         $file = $file->getPathname();
     }
     if (!is_readable($file)) {
         throw new \InvalidArgumentException("The given file must be a path to, or an \\SplFileInfo instance of a readable file");
     }
     return $this->responseHandler->getDocumentForCreation($this->sendRequest($this->clientManager->getUploadClient(), 'POST', 'documents', ['multipart' => [['name' => 'file', 'filename' => $fileName, 'contents' => fopen($file, 'r'), 'headers' => $fileHeaders], ['name' => 'non_svg', 'contents' => $nonSvg ? 'true' : 'false'], ['name' => 'name', 'contents' => $name], ['name' => 'thumbnails', 'contents' => implode(',', $thumbnails)]]]));
 }