Retrieve a collection of File objects representing the files stored inside a bucket.

@param array $options

@throws \Exception
@throws GuzzleException

@return array
1478
public function listFiles(array $options)
    {
        // if FileName is set, we only attempt to retrieve information about that single file.
        $fileName = !empty($options['FileName']) ? $options['FileName'] : null;

        $nextFileName = null;
        $maxFileCount = 1000;

        $prefix = isset($options['Prefix']) ? $options['Prefix'] : '';
        $delimiter = isset($options['Delimiter']) ? $options['Delimiter'] : null;

        $files = [];

        if (!isset($options['BucketId']) && isset($options['BucketName'])) {
            $options['BucketId'] = $this->getBucketIdFromName($options['BucketName']);
        }

        if ($fileName) {
            $nextFileName = $fileName;
            $maxFileCount = 1;
        }

        $this->authorizeAccount();

        // B2 returns, at most, 1000 files per "page". Loop through the pages and compile an array of File objects.
        while (true) {
            $response = $this->generateAuthenticatedClient([
                'bucketId'      => $options['BucketId'],
                'startFileName' => $nextFileName,
                'maxFileCount'  => $maxFileCount,
                'prefix'        => $prefix,
                'delimiter'     => $delimiter,
            ])->request('POST', '/b2_list_file_names');

            foreach ($response['files'] as $file) {
                // if we have a file name set, only retrieve information if the file name matches
                if (!$fileName || ($fileName === $file['fileName'])) {
                    $files[] = new File($file['fileId'], $file['fileName'], null, $file['size']);
                }
            }

            if ($fileName || $response['nextFileName'] === null) {
                // We've got all the files - break out of loop.
                break;
            }

            $nextFileName = $response['nextFileName'];
        }

        return $files;
    }
481694
public function getData(array $options)
    {
        $provider = $this->getProvider();

        $ownerDetails = $provider->getResourceOwner($this->accessToken);
        $data = $ownerDetails->toArray();

        return new Result([
            'externalId' => $data['id'],
            'name'       => $data['name'],
            'profileUrl' => $data['html_url'],
            'photoUrl'   => $data['avatar_url']
        ]);
    }
931368
protected function getFiles(array $source)
    {
        $fileSet = [];
        foreach ($source as $set) {
            if (!array_key_exists('files', $set)) {
                throw new \Exception("`src` must have a `files` option");
            }

            if (!array_key_exists('path', $set)) {
                $set['path'] = getcwd();
            }

            if (!array_key_exists('recursive', $set)) {
                $set['recursive'] = false;
            }

            $paths = is_array($set['path']) ? $set['path'] : [$set['path']];
            $files = is_array($set['files']) ? $set['files'] : [$set['files']];
            foreach ($paths as $path) {
                foreach ($files as $file) {
                    $finder = new Finder();
                    $finder->files()->in($path)->name($file);
                    if (!$set['recursive']) {
                        $finder->depth('== 0');
                    }

                    $fileSet = $this->appendFileSet($finder, $fileSet);
                }
            }
        }

        return $fileSet;
    }
194552
public function getCollection(array $options = array())
    {
        /** @var ClientEntity[] $collection */
        $collection = $this->getRepository()->findAll();
        $resource   = new Resource($this->generateBrowseUrl(), array('count' => count($collection)));

        foreach ($collection as $element) {
            $resource->setEmbedded('client', $this->createResourceFromClient($element));
        }

        return $resource;
    }
369128
public function getFiles($asArray = false)
    {
        $return = array();
        if ($asArray && $this->files) {
            foreach ($this->files as $file) {
                $return[] = $file->toArray();
            }
        }

        return $asArray ? $return : $this->files;
    }
1015886
public function listStashes(array $options = null)
    {
        $this->clearAll();
        $this->addCommandName(self::STASH_COMMAND . ' list');
        if (null !== $options) {
            $this->addCommandSubject($options);
        }
        return $this->getCommand();
    }
682286
public function get(array $options)
    {
        $options = $this->options($options);

        $response = $this->client->request('GET', $this->api_host.$this->api_prefix, $options);
        $content = $response->getBody()->getContents();

        $content = $this->repair->repair($content);
        $content = $this->detector->detect($content);

        return $content;
    }
862640
public function getQuery(array $options = array())
    {
        if ($this->query['type'] === Query::TYPE_MAP_REDUCE) {
            $this->hydrate = false;
        }

        $documentPersister = $this->dm->getUnitOfWork()->getDocumentPersister($this->class->name);

        $query = $this->query;

        $query['query'] = $this->expr->getQuery();
        $query['query'] = $documentPersister->addDiscriminatorToPreparedQuery($query['query']);
        $query['query'] = $documentPersister->addFilterToPreparedQuery($query['query']);

        $query['newObj'] = $this->expr->getNewObj();

        if (isset($query['select'])) {
            $query['select'] = $documentPersister->prepareSortOrProjection($query['select']);
        }

        if (isset($query['sort'])) {
            $query['sort'] = $documentPersister->prepareSortOrProjection($query['sort']);
        }

        if ($this->class->slaveOkay) {
            $query['slaveOkay'] = $this->class->slaveOkay;
        }

        return new Query(
            $this->dm,
            $this->class,
            $this->collection,
            $query,
            $options,
            $this->hydrate,
            $this->refresh,
            $this->primers,
            $this->requireIndexes
        );
    }
612499
public function getList(array $options = array())
    {
        $uri = $this->buildListResourceUri($this->listId);
        $response = $this->makeApiRequest($uri, $options);
        return $response->list;
    }
1272069
private static function retrieveFilesWithContents(Iterator $files): array
    {
        return array_reduce(
            iterator_to_array($files),
            static function (array $files, SplFileInfo $fileInfo): array {
                $file = $fileInfo->getRealPath();

                if (false === $file) {
                    throw new RuntimeException(
                        sprintf(
                            'Could not find the file "%s".',
                            (string) $fileInfo
                        )
                    );
                }

                if (false === is_readable($file)) {
                    throw new RuntimeException(
                        sprintf(
                            'Could not read the file "%s".',
                            $file
                        )
                    );
                }

                $files[$fileInfo->getRealPath()] = [$fileInfo->getRealPath(), file_get_contents($file)];

                return $files;
            },
            []
        );
    }
495391
public function getIndexs($collection, $options = [])
    {
        if (! $this->hasCollection($collection)) {
            return [];
        }

        $list = [];
        foreach ($this->db->selectCollection($collection)->listIndexes($options) as $index) {
            $list[] = $index->getName();
        }

        return $list;
    }
542472
public function getBucketLocation($bucketName, $options = array())
    {
        list($config) = $this->parseOptions($options, BosOptions::CONFIG);
        $response = $this->sendRequest(
            HttpMethod::GET,
            array(
                BosOptions::CONFIG => $config,
                'bucket_name' => $bucketName,
                'params' => array(
                    BosOptions::LOCATION => '',
                ),
            )
        );
        return $response->locationConstraint;
    }
1223408
public function getBucketWebsite($bucket, $options = NULL)
    {
        $this->precheckCommon($bucket, NULL, $options, false);
        $options[self::OSS_BUCKET] = $bucket;
        $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
        $options[self::OSS_OBJECT] = '/';
        $options[self::OSS_SUB_RESOURCE] = 'website';
        $response = $this->auth($options);
        $result = new GetWebsiteResult($response);
        return $result->getData();
    }
553761
public function getData($uri, $options = [])
    {
        return json_decode($this->request('GET', $uri, $options)->getBody()->getContents());
    }
601623
public function deleteFile(array $options)
    {
        if (!isset($options['FileName'])) {
            $file = $this->getFile($options);

            $options['FileName'] = $file->getName();
        }

        if (!isset($options['FileId']) && isset($options['BucketName']) && isset($options['FileName'])) {
            $file = $this->getFile($options);

            $options['FileId'] = $file->getId();
        }

        try {
            $this->generateAuthenticatedClient([
                'fileName' => $options['FileName'],
                'fileId'   => $options['FileId'],
            ])->request('POST', '/b2_delete_file_version');
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
57086
protected function retrievePaginatedListing(array $options)
    {
        $resultPaginator = $this->s3Client->getPaginator('ListObjects', $options);
        $listing = [];

        foreach ($resultPaginator as $result) {
            $listing = array_merge($listing, $result->get('Contents') ?: [], $result->get('CommonPrefixes') ?: []);
        }

        return $listing;
    }
172959
private function getObjectData($path, $options = array())
    {
        try {
            return $this->service->objects->get($this->bucket, $path, $options);
        } catch (\Google_Service_Exception $e) {
            return false;
        }
    }