Uploadcare\Api::getFileList PHP Method

getFileList() public method

This class provides iteration over all uploaded files. You can specify: - $options['from'] - a DateTime object or string from which objects will be iterated; - $options['to'] - a DateTime object or string to which objects will be iterated; - $options['limit'] - a total number of objects to be iterated; If not specified, all available objects are iterated; - $options['request_limit'] - a number of objects to be downloaded per request. - $options['stored'] - True to include only stored files, False to exclude, Null is default, will not exclude anything; - $options['removed'] - True to include only removed files, False to exclude, Null will not exclude anything. The default is False.
public getFileList ( array $options = [] ) : FileIterator
$options array
return FileIterator
    public function getFileList($options = array())
    {
        $options = array_replace(array('from' => null, 'to' => null, 'limit' => null, 'request_limit' => null, 'stored' => $this->defaultFilters['file']['stored'], 'removed' => $this->defaultFilters['file']['removed']), $options);
        if (!empty($options['from']) && !empty($options['to'])) {
            throw new \Exception('Only one of "from" and "to" arguments is allowed');
        }
        $options['from'] = self::dateTimeString($options['from']);
        $options['to'] = self::dateTimeString($options['to']);
        foreach ($this->defaultFilters['file'] as $k => $v) {
            if (!is_null($options[$k])) {
                $options[$k] = self::booleanString($options[$k]);
            }
        }
        return new \Uploadcare\FileIterator($this, $options);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Test that getFilesList method returns array
  * and each item of array is an object of Uploadcare\File class
  */
 public function testFileList()
 {
     $api = new Api(UC_PUBLIC_KEY, UC_SECRET_KEY);
     $files = $api->getFileList();
     $this->assertTrue(is_array($files));
     $this->assertEquals(20, count($files));
     $files = $api->getFileList(1, 2);
     $this->assertTrue(is_array($files));
     $this->assertEquals(2, count($files));
     foreach ($files as $file) {
         $this->assertTrue(get_class($file) == 'Uploadcare\\File');
     }
 }
All Usage Examples Of Uploadcare\Api::getFileList