/** * {@inheritdoc} */ public function listContents($dirname = '', $recursive = false) { $objectsIterator = $this->client->getIterator('listObjects', ['Bucket' => $this->bucket, 'Prefix' => $this->applyPathPrefix($dirname)]); $contents = iterator_to_array($objectsIterator); $result = array_map([$this, 'normalizeResponse'], $contents); $result = array_filter($result, function ($value) { return $value['path'] !== false; }); return Util::emulateDirectories($result); }
/** * List contents of a directory. * * @param string $directory * @param bool $recursive * * @return array */ public function listContents($directory = '', $recursive = false) { $prefix = $this->applyPathPrefix(rtrim($directory, '/') . '/'); $options = ['Bucket' => $this->bucket, 'Prefix' => ltrim($prefix, '/')]; if ($recursive === false) { $options['Delimiter'] = '/'; } $listing = $this->retrievePaginatedListing($options); $normalizer = [$this, 'normalizeResponse']; $normalized = array_map($normalizer, $listing); return Util::emulateDirectories($normalized); }
/** * @inheritdoc */ public function listContents($directory = '', $recursive = false) { $params = []; $sql = "SELECT * FROM {$this->pathTable}"; if (!empty($directory)) { $sql .= " WHERE path LIKE :prefix OR path = :path"; $params = ['prefix' => $directory . '/%', 'path' => $directory]; } $stmt = $this->db->prepare($sql); if (!$stmt->execute($params)) { return []; } $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); $rows = array_map([$this, 'normalizeMetadata'], $rows); if ($recursive) { $rows = Util::emulateDirectories($rows); } return $rows; }
/** * {@inheritdoc} */ public function listContents($dirname = '', $recursive = false) { $dirname = rtrim($dirname, '/') . '/'; $commandOptions = ['Bucket' => $this->bucket, 'Prefix' => $this->applyPathPrefix($dirname)]; $iteratorOptions = []; if (!$recursive) { $commandOptions['Delimiter'] = '/'; $iteratorOptions['return_prefixes'] = true; } $objectsIterator = $this->client->getIterator('listObjects', $commandOptions, $iteratorOptions); $contents = iterator_to_array($objectsIterator); $result = array_map([$this, 'normalizeResponse'], $contents); $result = array_filter($result, function ($value) { return $value['path'] !== false; }); return Util::emulateDirectories($result); }
/** * {@inheritdoc} */ public function listContents($dirname = '', $recursive = false) { $bucket = $this->bucket; $dir = $this->listDirObjects($dirname, true); $contents = $dir["objects"]; $result = array_map([$this, 'normalizeResponseOri'], $contents); $result = array_filter($result, function ($value) { return $value['path'] !== false; }); return Util::emulateDirectories($result); }
/** * Get a file's metadata * * @param string $path * @return array file metadata */ public function listContents($directory = '', $recursive = false) { $response = $this->container->objectList(array('prefix' => $directory)); $response = iterator_to_array($response); $contents = array_map(array($this, 'normalizeObject'), $response); return Util::emulateDirectories($contents); }
/** * {@inheritdoc} */ public function listContents($directory = '', $recursive = false) { $directory = $this->applyPathPrefix($directory); // Append trailing slash only for directory other than root (which after normalization is an empty string). // Listing for / doesn't work properly otherwise. if (strlen($directory)) { $directory = rtrim($directory, '/') . '/'; } $options = new ListBlobsOptions(); $options->setPrefix($directory); if (!$recursive) { $options->setDelimiter('/'); } /** @var ListBlobsResult $listResults */ $listResults = $this->client->listBlobs($this->container, $options); $contents = []; foreach ($listResults->getBlobs() as $blob) { $contents[] = $this->normalizeBlobProperties($blob->getName(), $blob->getProperties()); } if (!$recursive) { $contents = array_merge($contents, array_map([$this, 'normalizeBlobPrefix'], $listResults->getBlobPrefixes())); } return Util::emulateDirectories($contents); }
/** * List contents of a directory. * * @param string $directory * @param bool $recursive * * @return array */ public function listContents($directory = '', $recursive = false) { $prefix = $this->applyPathPrefix(rtrim($directory, '/') . '/'); $options = ['Bucket' => $this->bucket, 'Prefix' => ltrim($prefix, '/')]; $iterator = $this->s3Client->getIterator('ListObjects', $options); $normalizer = [$this, 'normalizeResponse']; $normalized = array_map($normalizer, iterator_to_array($iterator)); return Util::emulateDirectories($normalized); }
/** * List contents of a directory * * @param string $dirname * @param bool $recursive * @return array directory contents */ public function listContents($dirname = '', $recursive = false) { if ($dirname == '') { $dirname = "root"; } $dirname = basename($dirname); $parameters = array(); $result = array(); do { try { if (isset($pageToken)) { $parameters['pageToken'] = $pageToken; } $files = $this->service->children->listChildren($dirname, $parameters); foreach ($files as $file) { $meta = (array) $this->service->files->get($file['id'], $parameters); if ($dirname == "root") { } else { $meta['dirname'] = $dirname; } $result = array_merge($result, array($meta)); } //$result = array_merge($result, $files->getItems()); $pageToken = $files->getNextPageToken(); } catch (Exception $e) { print "An error occurred: " . $e->getMessage(); $pageToken = NULL; } } while ($pageToken); $result = array_map(array($this, 'normalizeObject'), $result); return Util::emulateDirectories($result); }
/** * List contents of a directory * * @param string $dirname * @param bool $recursive * @return array directory contents */ public function listContents($dirname = '', $recursive = false) { $objectsIterator = $this->client->getIterator('listObjects', array('Bucket' => $this->bucket, 'Prefix' => $this->prefix($dirname))); $contents = iterator_to_array($objectsIterator); $result = array_map(array($this, 'normalizeObject'), $contents); return Util::emulateDirectories($result); }
/** * List contents of a directory. * * @param string $directory * @param bool $recursive * * @return array */ public function listContents($directory = '', $recursive = false) { $keys = $this->client->keys($directory . '/*'); $values = []; foreach ($keys as $key) { if (!$recursive && preg_match("|{$directory}/.+/|", $key) !== 0) { continue; } $stream = tmpfile(); fwrite($stream, $this->client->get($key)); rewind($stream); $values[$key] = ['mimetype' => Util::guessMimeType(stream_get_meta_data($stream)['uri'], stream_get_contents($stream)), 'type' => 'file']; } return Util::emulateDirectories($values); }
/** * {@inheritdoc} */ public function listContents($directory = '', $recursive = false) { $location = $this->applyPathPrefix($directory); $response = $this->container->objectList(['prefix' => $location]); $response = iterator_to_array($response); $contents = array_map([$this, 'normalizeObject'], $response); return Util::emulateDirectories($contents); }
/** * {@inheritdoc} */ public function listContents($directory = '', $recursive = false) { $directory = $this->applyPathPrefix($directory); $objects = $this->bucket->objects(['prefix' => $directory]); $normalised = []; foreach ($objects as $object) { $normalised[] = $this->normaliseObject($object); } return Util::emulateDirectories($normalised); }
/** * @inheritdoc */ public function listContents($directory = '', $recursive = false) { $options = new ListBlobsOptions(); $options->setPrefix($directory); /** @var ListBlobsResult $listResults */ $listResults = $this->client->listBlobs($this->container, $options); $contents = []; foreach ($listResults->getBlobs() as $blob) { $contents[] = $this->normalizeBlobProperties($blob->getName(), $blob->getProperties()); } return Util::emulateDirectories($contents); }
/** * {@inheritdoc} */ public function listContents($directory = '', $recursive = false) { $response = []; $marker = null; $location = $this->applyPathPrefix($directory); while (true) { $objectList = $this->client->listObjects(['Bucket' => $this->bucket, 'Prefix' => $location, 'Marker' => $marker, 'MaxKeys' => 100]); $objectSummarys = $objectList->getObjectSummarys(); if (!$objectSummarys || count($objectSummarys) === 0) { break; } foreach ($objectSummarys as $summary) { if ($summary) { $object = $this->getObject($this->removePathPrefix($summary->getKey())); if (!$object) { continue; } $response[] = $object; $marker = $object->getKey(); } } } return Util::emulateDirectories(array_map([$this, 'normalizeObject'], $response)); }
/** * List contents of a directory * * @param string $dirname * @param bool $recursive * @return array directory contents */ public function listContents($dirname = '', $recursive = false) { $result = $this->client->listObjects(array('Bucket' => $this->bucket))->getAll(array('Contents')); $contents = isset($result['Contents']) ? $result['Contents'] : array(); $result = array_map(array($this, 'normalizeObject'), $contents); return Util::emulateDirectories($result); }
/** * {@inheritdoc} */ public function listContents($directory = '', $recursive = false) { $results = []; $pageToken = null; while (true) { $params = []; if ($pageToken) { $params['pageToken'] = $pageToken; } $objects = $this->service->objects->listObjects($this->bucket, $params); $results = array_merge($results, $objects->getItems()); $pageToken = $objects->getNextPageToken(); if ($pageToken === null) { break; } } $results = array_map(function (\Google_Service_Storage_StorageObject $object) { return $this->normaliseObject($object); }, $results); return Util::emulateDirectories($results); }
/** * {@inheritdoc} */ public function listContents($directory = '', $recursive = false) { $response = []; $marker = null; $location = $this->applyPathPrefix($directory); while (true) { $objectList = $this->container->objectList(['prefix' => $location, 'marker' => $marker]); if ($objectList->count() === 0) { break; } $response = array_merge($response, iterator_to_array($objectList)); $marker = end($response)->getName(); } return Util::emulateDirectories(array_map([$this, 'normalizeObject'], $response)); }
/** * @inheritdoc */ public function listContents($directory = '', $recursive = false) { $options = ['marker' => 2000, 'max-keys' => 1000, 'bucket' => $this->bucket, 'prefix' => $directory]; $data = $this->client->getBucket($options); $result = []; foreach ($data->Contents as $v) { $result[] = ['type' => (int) $v->Size > 0 ? 'file' : 'dir', 'dirname' => Util::dirname($v->Key), 'path' => rtrim($v->Key, '/'), 'timestamp' => strtotime($v->LastModified), 'mimetype' => MimeType::detectByFileExtension(pathinfo($v->Key, PATHINFO_EXTENSION)), 'size' => (int) $v->Size]; } return Util::emulateDirectories($result); }