Exemple #1
0
 /**
  * Test that getFilesList mehtod returns array
  * and each item of array is an object of Uploadcare_File class
  */
 public function testFileList()
 {
     $api = new Uploadcare_Api(UC_PUBLIC_KEY, UC_SECRET_KEY);
     $files = $api->getFileList();
     $this->assertTrue(is_array($files));
     foreach ($files as $file) {
         $this->assertTrue(get_class($file) == 'Uploadcare_File');
     }
 }
 *  - original_filename
 *  - removed
 *  - mime_type
 *  - original_file_url
 *
*/
$files_raw = $api->request('GET', '/files/');
/**
 *  Previous request is just some raw request and it will return raw data from json.
 *  There's a better way to handle all the files by using method below.
 *  It will return an array of \Uploadcare\File objects to work with.
 *
 *  This objects don't provide all the data like in previous request, but provides ways to display the file
 *  and to use methods such as resize, crop, etc
*/
$files = $api->getFileList();
/**
 * getFileList called without any params will return just an array of first 20 files objects (first page).
 *
 * But you can supply a page you want to see:
*/
$page = 2;
$files = $api->getFileList($page);
/**
 * You can get some information about pagination.
 *
 * 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