コード例 #1
0
 function ConvertToDB($arProperty, $value)
 {
     $value = $value['VALUE'];
     if (!$value) {
         return array('VALUE' => '');
     }
     if (strpos($value, 'ucarecdn.com')) {
         $parts = parse_url($value);
         $path = $parts['path'];
         $path_parts = explode('/', $path);
         $file_id = $path_parts[1];
     } else {
         $file_id = $value;
     }
     $public_key = COption::GetOptionString("uploadcare", "publickey");
     $secret_key = COption::GetOptionString("uploadcare", "secretkey");
     $uploadcare_api = new Uploadcare_Api($public_key, $secret_key);
     $file = $uploadcare_api->getFile($file_id);
     $file->store();
     $arResult = array('VALUE' => $value);
     return $arResult;
 }
コード例 #2
0
 * You will get an array with params:
 * - page: current page
 * - next: uri to request next page
 * - per_page: number of files per page
 * - pages: number of pages
 * - previous: uri to request previous page
 *
 * Use "per_page" and "pages" information to create pagination inside your own project
*/
$pagination_info = $api->getFilePaginationInfo();
/**
 * If you have a file_id (for example, it's saved in your database) you can create object for file easily.
 * Just user request below
*/
$file_id = '5255b9dd-f790-425e-9fa9-8b49d4e64643';
$file = $api->getFile($file_id);
/**
 * Ok, using object of \Uploadcare\File class we can get url for the file
*/
echo $file->getUrl() . "\n";
/**
 * Or even get an image tag
 */
echo $file->getImgTag('image.jpg', array('alt' => 'Somealt')) . "\n";
/**
 * Now let's do some crop.
 */
$width = 400;
$height = 400;
$is_center = true;
$fill_color = 'ff0000';
コード例 #3
0
ファイル: ApiTest.php プロジェクト: nemoluv/pushwing
 /**
  * Let's check the file operations and check for correct urls
  */
 public function testFile()
 {
     $api = new Uploadcare_Api(UC_PUBLIC_KEY, UC_SECRET_KEY);
     $file = $api->getFile('4bd3a897-f489-4b9f-b643-961b1c9f657e');
     $this->assertEquals(get_class($file), 'Uploadcare_File');
     $this->assertEquals($file->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/');
     $this->assertEquals($file->resize(400, 400)->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/resize/400x400/');
     $this->assertEquals($file->resize(400, false)->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/resize/400x/');
     $this->assertEquals($file->resize(false, 400)->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/resize/x400/');
     $this->assertEquals($file->crop(400, 400)->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/crop/400x400/');
     $this->assertEquals($file->crop(400, 400, true)->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/crop/400x400/center/');
     $this->assertEquals($file->crop(400, 400, true, 'ff0000')->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/crop/400x400/center/ff0000/');
     $this->assertEquals($file->crop(400, 400, false, 'ff0000')->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/crop/400x400/ff0000/');
     $this->assertEquals($file->scaleCrop(400, 400)->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/scale_crop/400x400/');
     $this->assertEquals($file->scaleCrop(400, 400, true)->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/scale_crop/400x400/center/');
     $this->assertEquals($file->effect('flip')->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/effect/flip/');
     $this->assertEquals($file->effect('grayscale')->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/effect/grayscale/');
     $this->assertEquals($file->effect('invert')->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/effect/invert/');
     $this->assertEquals($file->effect('mirror')->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/effect/mirror/');
     $this->assertEquals($file->effect('flip')->effect('mirror')->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/effect/flip/-/effect/mirror/');
     $this->assertEquals($file->effect('mirror')->effect('flip')->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/effect/mirror/-/effect/flip/');
     $this->assertEquals($file->resize(400, 400)->scaleCrop(200, 200, true)->effect('mirror')->getUrl(), 'https://ucarecdn.com/4bd3a897-f489-4b9f-b643-961b1c9f657e/-/resize/400x400/-/scale_crop/200x200/center/-/effect/mirror/');
 }
コード例 #4
0
<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/tools/uploadcare/uploadcare-php/uploadcare/lib/5.2/Uploadcare.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
$public_key = COption::GetOptionString("uploadcare", "publickey");
$secret_key = COption::GetOptionString("uploadcare", "secretkey");
$uploadcare_api = new Uploadcare_Api($public_key, $secret_key);

$file_id = $_GET['file_id'];
$file = $uploadcare_api->getFile($file_id);
$file->store();
print 'OK';