Example #1
0
 function __construct($response)
 {
     parent::__construct(\Cloudinary\Api::parse_json_response($response));
     $this->rate_limit_reset_at = strtotime($response->headers["X-FeatureRateLimit-Reset"]);
     $this->rate_limit_allowed = intval($response->headers["X-FeatureRateLimit-Limit"]);
     $this->rate_limit_remaining = intval($response->headers["X-FeatureRateLimit-Remaining"]);
 }
 public function get(RootFile $file)
 {
     try {
         $api = new Api();
         $result = $api->resource(sprintf('%s/%s', $file->getUploaderPath(), $file->getBasename('.' . $file->getExtension())));
         $file->setType($result['resource_type'] === 'image' ? 'image' : 'file');
         if ($result['resource_type'] === 'image') {
             $config = $this->uploaderConfig->get('thumbnails');
             $edition = new Edition("thumbnail", null, $file->getUploaderPath(), ['type' => 'image', 'height' => $config['height'], 'width' => $config['width'], 'crop' => $config['crop'], 'cloudinary_response' => $result], true);
             $edition->setUrl($this->resolveUrl($edition));
             $file->addEdition($edition);
         }
         return $file;
     } catch (Api\NotFound $e) {
         return ['error' => 'S0001'];
     }
 }
Example #3
0
 function test_update_parameters()
 {
     Curl::mockApi($this);
     $this->api->update(self::$api_test, array("auto_tagging" => 0.5));
     assertUrl($this, '/resources/image/upload/' . self::$api_test);
     assertParam($this, "auto_tagging", 0.5);
     $fields = Curl::$instance->fields();
     $this->assertArrayNotHasKey("face_coordinates", $fields, "update() should not send empty parameters");
     $this->assertArrayNotHasKey("tags", $fields, "update() should not send empty parameters");
     $this->assertArrayNotHasKey("context", $fields, "update() should not send empty parameters");
     $this->assertArrayNotHasKey("face_coordinates", $fields, "update() should not send empty parameters");
     $this->assertArrayNotHasKey("custom_coordinates", $fields, "update() should not send empty parameters");
 }
 function test35_upload_mapping()
 {
     try {
         $this->api->delete_upload_mapping("api_test_upload_mapping");
     } catch (Exception $e) {
     }
     $this->api->create_upload_mapping("api_test_upload_mapping", array("template" => "http://cloudinary.com"));
     $result = $this->api->upload_mapping("api_test_upload_mapping");
     $this->assertEquals($result["template"], "http://cloudinary.com");
     $this->api->update_upload_mapping("api_test_upload_mapping", array("template" => "http://res.cloudinary.com"));
     $result = $this->api->upload_mapping("api_test_upload_mapping");
     $this->assertEquals($result["template"], "http://res.cloudinary.com");
     $result = $this->api->upload_mappings();
     $this->assertContains(array("folder" => "api_test_upload_mapping", "template" => "http://res.cloudinary.com"), $result["mappings"]);
     $this->api->delete_upload_mapping("api_test_upload_mapping");
     $result = $this->api->upload_mappings();
     $this->assertNotContains("api_test_upload_mapping", $result["mappings"]);
 }
Example #5
0
 function test_upload_preset()
 {
     // should support unsigned uploading using presets
     $api = new \Cloudinary\Api();
     $preset = $api->create_upload_preset(array("folder" => "upload_folder", "unsigned" => TRUE));
     $result = Uploader::unsigned_upload(self::LOGO_PNG, $preset["name"]);
     $this->assertRegExp('/^upload_folder\\/[a-z0-9]+$/', $result["public_id"]);
     $api->delete_upload_preset($preset["name"]);
 }
 /**
  * Get Resource data
  * @param  string $path
  * @return array
  */
 public function getResource($path)
 {
     return (array) $this->api->resource($path);
 }
Example #7
0
 /**
  * @expectedException \Cloudinary\Api\NotFound
  */
 function test33_folder_listing_error()
 {
     $this->api->subfolders("test_folder");
 }