#1879·flysystem

Support prefix filtering on listContents() for file name prefixes (not only “directory” prefixes)

Author: lamouize-actCreated Oct 2, 2025Updated Oct 2, 2025

Currently, the GoogleCloudStorageAdapter::listContents() method automatically appends a / to the provided path to build the prefix option for the underlying Bucket::objects() call:

if (! empty($prefixedPath)) { $options = ['prefix' => sprintf('%s/', rtrim($prefixedPath, '/'))]; }

This means that listContents('incoming') correctly lists objects under incoming/, but calling: listContents('incoming/prefix_file_', false)

does not list objects whose names start with prefix_file_, because the adapter is forcing a “directory-like” behavior by appending /.

This is a limitation, because Google Cloud Storage natively supports prefix filtering for arbitrary filename prefixes, not just directory prefixes.

Why this matters • This matches GCS’s native capabilities (prefix filtering is powerful & efficient server-side). • It avoids listing entire buckets and filtering client-side for common patterns. • It allows Flysystem users to use listContents() for real-world scenarios with file prefixes at scale.